|
@@ -25,10 +25,7 @@ export default {
|
|
data: function() {
|
|
data: function() {
|
|
return {
|
|
return {
|
|
fields: [],
|
|
fields: [],
|
|
- account: {
|
|
|
|
- version: 1,
|
|
|
|
- fields: {}
|
|
|
|
- }
|
|
|
|
|
|
+ account: {}
|
|
};
|
|
};
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
@@ -43,7 +40,8 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
props: {
|
|
props: {
|
|
- onSubmit: Function
|
|
|
|
|
|
+ onSubmit: Function,
|
|
|
|
+ initialAccount: Object
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
io.getSocket(socket => {
|
|
io.getSocket(socket => {
|
|
@@ -51,19 +49,26 @@ export default {
|
|
|
|
|
|
socket.emit("getAccountSchema", res => {
|
|
socket.emit("getAccountSchema", res => {
|
|
this.fields = res.schema.fields;
|
|
this.fields = res.schema.fields;
|
|
- this.fields.forEach(field => {
|
|
|
|
- let defaultObject = {};
|
|
|
|
- field.fieldTypes.forEach(fieldType => {
|
|
|
|
- if (fieldType.type === "text" || fieldType.type === "select") defaultObject[fieldType.fieldTypeId] = "";
|
|
|
|
- else if (fieldType.type === "checkbox") defaultObject[fieldType.fieldTypeId] = false;
|
|
|
|
- });
|
|
|
|
|
|
+ if (!this.initialAccount) {
|
|
|
|
+ this.account.fields = {};
|
|
|
|
+ this.account.version = res.schema.version;
|
|
|
|
|
|
- this.account.fields[field.fieldId] = [];
|
|
|
|
|
|
+ this.fields.forEach(field => {
|
|
|
|
+ let defaultObject = {};
|
|
|
|
+ field.fieldTypes.forEach(fieldType => {
|
|
|
|
+ if (fieldType.type === "text" || fieldType.type === "select") defaultObject[fieldType.fieldTypeId] = "";
|
|
|
|
+ else if (fieldType.type === "checkbox") defaultObject[fieldType.fieldTypeId] = false;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ this.account.fields[field.fieldId] = [];
|
|
|
|
|
|
- for(let i = 0; i < field.minEntries; i++) {
|
|
|
|
- this.account.fields[field.fieldId].push(defaultObject);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ for(let i = 0; i < field.minEntries; i++) {
|
|
|
|
+ this.account.fields[field.fieldId].push(defaultObject);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ this.account = this.initialAccount;
|
|
|
|
+ }
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}
|
|
}
|