Skip to content
Permalink
Browse files

fix(table): allow tables to have documents as value

  • Loading branch information...
anehx authored and czosel committed Jun 24, 2019
1 parent b47cd4d commit 017515f970202a5dbd89692a3cbabefab3805fd9
Showing with 7 additions and 6 deletions.
  1. +3 −6 addon/components/cf-field/input/table.js
  2. +4 −0 addon/lib/answer.js
@@ -68,10 +68,7 @@ export default Component.extend(ComponentQueryManager, {
doc => doc.id !== document.id
);

// update client-side state
this.set("field.answer.value", remainingDocuments);

yield this.onSave(remainingDocuments.map(doc => doc.id));
yield this.onSave(remainingDocuments);
}),

save: task(function*() {
@@ -86,13 +83,13 @@ export default Component.extend(ComponentQueryManager, {

if (!rows.find(doc => doc.id === newDocument.id)) {
// add document to table
yield this.onSave([...rows.map(doc => doc.id), newDocument.id]);
yield this.onSave([...rows, newDocument]);

this.get("notification").success(
this.get("intl").t("caluma.form.notification.table.add.success")
);
} else {
yield this.onSave([...rows.map(doc => doc.id)]);
yield this.onSave([...rows]);
}

this.set("showModal", false);
@@ -58,6 +58,10 @@ export default EmberObject.extend({
return value;
},
set(_, value) {
if (this.__typename === "TableAnswer") {
value = value.map(doc => doc.id);
}

if (this._valueKey) {
this.set(this._valueKey, value);
}

0 comments on commit 017515f

Please sign in to comment.
You can’t perform that action at this time.