Commit 0d3ad7ac authored by Vincent Bechu's avatar Vincent Bechu

[Officejs] Remove editable from views

parent d38ec55d
......@@ -23,13 +23,12 @@
.declareMethod("render", function (options) {
return this.changeState({
jio_key: options.jio_key,
doc: options.doc,
editable: options.editable ? 1 : 0
doc: options.doc
});
})
.onEvent('submit', function () {
var gadget = this, doc;
var gadget = this;
return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
......@@ -38,12 +37,6 @@
return form_gadget.getContent();
})
.push(function (content) {
if (gadget.state.editable) {
return jIO.util.dataURItoBlob(content)
.push(function (blob) {
return gadget.jio_putAttachment(gadget.state.doc.jio_key, "data", blob);
});
}
return gadget.updateDocument(content);
})
.push(function () {
......@@ -78,7 +71,6 @@
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
var editable = gadget.state.editable;
return form_gadget.render({
erp5_document: {
"_embedded": {"_view": {
......@@ -88,9 +80,9 @@
"default": gadget.state.doc.title,
"css_class": "",
"required": 1,
"editable": 1 - editable,
"editable": 1,
"key": "title",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_reference": {
......@@ -99,9 +91,9 @@
"default": gadget.state.doc.reference,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "reference",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_version": {
......@@ -110,9 +102,9 @@
"default": gadget.state.doc.version,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "version",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_language": {
......@@ -121,9 +113,9 @@
"default": gadget.state.doc.language,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "language",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_description": {
......@@ -132,19 +124,19 @@
"default": gadget.state.doc.description,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "description",
"hidden": editable,
"hidden": 0,
"type": "TextAreaField"
},
"my_content": {
"default": data,
"css_class": editable === 1 ? "content-iframe-maximize" : "",
"css_class": "",
"required": 0,
"editable": editable,
"editable": 1,
"key": "text_content",
"hidden": 0,
"type": editable === 1 ? "GadgetField" : "EditorField",
"type": "GadgetField",
"url": "../officejs_pdf_viewer_gadget/app/",
"sandbox": "iframe"
}
......@@ -171,24 +163,17 @@
return RSVP.all([
gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: 'selection_previous'}),
gadget.getUrlFor({command: 'selection_next'}),
gadget.getUrlFor({command: "change", options: {editable: true}})
gadget.getUrlFor({command: 'selection_next'})
]);
})
.push(function (url_list) {
var header_dict = {
return gadget.updateHeader({
page_title: gadget.state.doc.title,
selection_url: url_list[0],
previous_url: url_list[1],
next_url: url_list[2],
save_action: true
};
if (gadget.state.editable) {
header_dict.edit_properties = url_list[3].replace("n.editable=true", "").replace("p.editable=true", "");
} else {
header_dict.edit_content = url_list[3];
}
return gadget.updateHeader(header_dict);
save_action: true,
previous_url : url_list[1],
next_url : url_list[2]
});
});
});
}(window, rJS, RSVP, jIO, Blob));
......@@ -233,7 +233,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.37367.12390.34440</string> </value>
<value> <string>964.5644.25223.9574</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -251,7 +251,7 @@
</tuple>
<state>
<tuple>
<float>1507276424.45</float>
<float>1513091327.7</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -21,8 +21,7 @@
.declareMethod("render", function (options) {
return this.changeState({
jio_key: options.jio_key,
doc: options.doc,
editable: options.editable ? 1 : 0
doc: options.doc
});
})
......@@ -51,7 +50,6 @@
var gadget = this;
return gadget.getDeclaredGadget('form_view')
.push(function (form_gadget) {
var editable = gadget.state.editable;
return form_gadget.render({
erp5_document: {"_embedded": {"_view": {
"my_title": {
......@@ -60,9 +58,9 @@
"default": gadget.state.doc.title,
"css_class": "",
"required": 1,
"editable": 1 - editable,
"editable": 1,
"key": "title",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_reference": {
......@@ -71,9 +69,9 @@
"default": gadget.state.doc.reference,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "reference",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_version": {
......@@ -82,9 +80,9 @@
"default": gadget.state.doc.version,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "version",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_language": {
......@@ -93,9 +91,9 @@
"default": gadget.state.doc.language,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "language",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_description": {
......@@ -104,19 +102,19 @@
"default": gadget.state.doc.description,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "description",
"hidden": editable,
"hidden": 0,
"type": "TextAreaField"
},
"my_content": {
"default": gadget.state.doc.text_content,
"css_class": editable === 1 ? "content-iframe-maximize" : "",
"css_class": "",
"required": 0,
"editable": editable,
"editable": 1,
"key": "text_content",
"hidden": 0,
"type": editable === 1 ? "GadgetField" : "EditorField",
"type": "GadgetField",
"url": "../officejs_svg_editor_gadget/" +
"app/method-draw/method-draw.gadget.html",
"sandbox": "iframe"
......@@ -143,24 +141,17 @@
return RSVP.all([
gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: 'selection_previous'}),
gadget.getUrlFor({command: 'selection_next'}),
gadget.getUrlFor({command: "change", options: {editable: true}})
gadget.getUrlFor({command: 'selection_next'})
]);
})
.push(function (url_list) {
var header_dict = {
return gadget.updateHeader({
page_title: gadget.state.doc.title,
selection_url: url_list[0],
previous_url: url_list[1],
next_url: url_list[2],
save_action: true
};
if (gadget.state.editable) {
header_dict.edit_properties = url_list[3].replace("n.editable=true", "").replace("p.editable=true", "");
} else {
header_dict.edit_content = url_list[3];
}
return gadget.updateHeader(header_dict);
save_action: true,
previous_url : url_list[1],
next_url : url_list[2]
});
});
});
}(window, rJS, RSVP));
......@@ -273,7 +273,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>963.3430.40377.1177</string> </value>
<value> <string>963.49321.32568.53862</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -291,7 +291,7 @@
</tuple>
<state>
<tuple>
<float>1510310205.61</float>
<float>1513090098.94</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -21,8 +21,7 @@
.declareMethod("render", function (options) {
return this.changeState({
jio_key: options.jio_key,
doc: options.doc,
editable: options.editable ? 1 : 0
doc: options.doc
});
})
......@@ -51,7 +50,6 @@
var gadget = this;
return gadget.getDeclaredGadget('form_view')
.push(function (form_gadget) {
var editable = gadget.state.editable;
return form_gadget.render({
erp5_document: {
"_embedded": {"_view": {
......@@ -61,9 +59,9 @@
"default": gadget.state.doc.title,
"css_class": "",
"required": 1,
"editable": 1 - editable,
"editable": 1,
"key": "title",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_reference": {
......@@ -72,9 +70,9 @@
"default": gadget.state.doc.reference,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "reference",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_version": {
......@@ -83,9 +81,9 @@
"default": gadget.state.doc.version,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "version",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_language": {
......@@ -94,9 +92,9 @@
"default": gadget.state.doc.language,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "language",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_description": {
......@@ -105,19 +103,19 @@
"default": gadget.state.doc.description,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "description",
"hidden": editable,
"hidden": 0,
"type": "TextAreaField"
},
"my_content": {
"default": gadget.state.doc.text_content,
"css_class": editable === 1 ? "content-iframe-maximize" : "",
"css_class": "",
"required": 0,
"editable": editable,
"editable": 1,
"key": "text_content",
"hidden": 0,
"type": editable === 1 ? "GadgetField" : "EditorField",
"type": "GadgetField",
"url": "../officejs_ckeditor_gadget/app/",
"sandbox": "iframe"
}
......@@ -144,22 +142,17 @@
return RSVP.all([
gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: 'selection_previous'}),
gadget.getUrlFor({command: 'selection_next'}),
gadget.getUrlFor({command: "change", options: {editable: true}})
gadget.getUrlFor({command: 'selection_next'})
]);
})
.push(function (url_list) {
var header_dict = {
return gadget.updateHeader({
page_title: gadget.state.doc.title,
selection_url: url_list[0],
save_action: true
};
if (!gadget.state.editable) {
header_dict.previous_url = url_list[1];
header_dict.next_url = url_list[2];
header_dict.edit_content = url_list[3];
}
return gadget.updateHeader(header_dict);
save_action: true,
previous_url : url_list[1],
next_url : url_list[2]
});
});
});
}(window, rJS, RSVP));
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.37368.2625.44083</string> </value>
<value> <string>964.5587.42141.48196</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1507276723.18</float>
<float>1513090096.0</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -23,13 +23,12 @@
.declareMethod("render", function (options) {
return this.changeState({
jio_key: options.jio_key,
doc: options.doc,
editable: options.editable ? 1 : 0
doc: options.doc
});
})
.onEvent('submit', function () {
var gadget = this, doc;
var gadget = this, data;
return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
......@@ -38,16 +37,18 @@
return form_gadget.getContent();
})
.push(function (content) {
if (gadget.state.editable) {
return new RSVP.Queue()
.push(function () {
return jIO.util.dataURItoBlob(content.text_content);
data = content.text_content;
content.text_content = undefined;
return gadget.updateDocument(content);
})
.push(function (blob) {
return gadget.jio_putAttachment(gadget.state.jio_key, "data", blob);
});
.push(function () {
if (gadget.state.content_editable) {
return gadget.jio_putAttachment(
gadget.state.jio_key,
"data",
jIO.util.dataURItoBlob(data)
);
}
return gadget.updateDocument(content);
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
......@@ -76,7 +77,6 @@
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
var editable = gadget.state.editable;
return form_gadget.render({
erp5_document: {
"_embedded": {"_view": {
......@@ -86,9 +86,9 @@
"default": gadget.state.doc.title,
"css_class": "",
"required": 1,
"editable": 1 - editable,
"editable": 1,
"key": "title",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_reference": {
......@@ -97,9 +97,9 @@
"default": gadget.state.doc.reference,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "reference",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_version": {
......@@ -108,9 +108,9 @@
"default": gadget.state.doc.version,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "version",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_language": {
......@@ -119,9 +119,9 @@
"default": gadget.state.doc.language,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "language",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_description": {
......@@ -130,19 +130,19 @@
"default": gadget.state.doc.description,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "description",
"hidden": editable,
"hidden": 0,
"type": "TextAreaField"
},
"my_content": {
"default": editable ? data : data.blob,
"css_class": editable === 1 ? "content-iframe-maximize" : "",
"default": data,
"css_class": "",
"required": 0,
"editable": editable,
"editable": 1,
"key": "text_content",
"hidden": 0,
"type": editable === 1 ? "GadgetField" : "ImageField",
"type": "GadgetField",
"url": "../officejs_image_editor_gadget/app/",
"sandbox": "iframe"
}
......@@ -169,24 +169,17 @@
return RSVP.all([
gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: 'selection_previous'}),
gadget.getUrlFor({command: 'selection_next'}),
gadget.getUrlFor({command: "change", options: {editable: true}})
gadget.getUrlFor({command: 'selection_next'})
]);
})
.push(function (url_list) {
var header_dict = {
return gadget.updateHeader({
page_title: gadget.state.doc.title,
selection_url: url_list[0],
previous_url: url_list[1],
next_url: url_list[2],
save_action: true
};
if (gadget.state.editable) {
header_dict.edit_properties = url_list[3].replace("n.editable=true", "").replace("p.editable=true", "");
} else {
header_dict.edit_content = url_list[3];
}
return gadget.updateHeader(header_dict);
save_action: true,
previous_url : url_list[1],
next_url : url_list[2]
});
});
});
}(window, rJS, RSVP, jIO, Blob));
......@@ -235,7 +235,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.54506.51685.58146</string> </value>
<value> <string>964.5641.61141.26828</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -253,7 +253,7 @@
</tuple>
<state>
<tuple>
<float>1508245149.26</float>
<float>1513091333.42</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -21,8 +21,7 @@
.declareMethod("render", function (options) {
return this.changeState({
jio_key: options.jio_key,
doc: options.doc,
editable: options.editable ? 1 : 0
doc: options.doc
});
})
......@@ -51,7 +50,6 @@
var gadget = this;
return gadget.getDeclaredGadget('form_view')
.push(function (form_gadget) {
var editable = gadget.state.editable;
return form_gadget.render({
erp5_document: {"_embedded": {"_view": {
"my_title": {
......@@ -60,9 +58,9 @@
"default": gadget.state.doc.title,
"css_class": "",
"required": 1,
"editable": 1 - editable,
"editable": 1,
"key": "title",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_reference": {
......@@ -71,9 +69,9 @@
"default": gadget.state.doc.reference,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "reference",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_version": {
......@@ -82,9 +80,9 @@
"default": gadget.state.doc.version,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "version",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_language": {
......@@ -93,9 +91,9 @@
"default": gadget.state.doc.language,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "language",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_description": {
......@@ -104,19 +102,19 @@
"default": gadget.state.doc.description,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "description",
"hidden": editable,
"hidden": 0,
"type": "TextAreaField"
},
"my_content": {
"default": gadget.state.doc.text_content,
"css_class": editable === 1 ? "content-iframe-maximize" : "",
"css_class": "",
"required": 0,
"editable": editable,
"editable": 1,
"key": "text_content",
"hidden": 0,
"type": editable === 1 ? "GadgetField" : "EditorField",
"type": "GadgetField",
"url": "../officejs_web_table_editor_gadget/app/",
"sandbox": "iframe"
}
......@@ -142,24 +140,17 @@
return RSVP.all([
gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: 'selection_previous'}),
gadget.getUrlFor({command: 'selection_next'}),
gadget.getUrlFor({command: "change", options: {editable: true}})
gadget.getUrlFor({command: 'selection_next'})
]);
})
.push(function (url_list) {
var header_dict = {
return gadget.updateHeader({
page_title: gadget.state.doc.title,
selection_url: url_list[0],
previous_url: url_list[1],
next_url: url_list[2],
save_action: true
};
if (gadget.state.editable) {
header_dict.edit_properties = url_list[3].replace("n.editable=true", "").replace("p.editable=true", "");
} else {
header_dict.edit_content = url_list[3];
}
return gadget.updateHeader(header_dict);
save_action: true,
previous_url : url_list[1],
next_url : url_list[2]
});
});
});
}(window, rJS, RSVP));
......@@ -227,7 +227,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.47399.35230.56951</string> </value>
<value> <string>964.5638.24467.20428</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -245,7 +245,7 @@
</tuple>
<state>
<tuple>
<float>1508245160.26</float>
<float>1513091035.01</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -23,14 +23,13 @@
return this.changeState({
jio_key: options.jio_key,
doc: options.doc,
editable: options.editable ? 1 : 0,
content_editable: options.doc.content_type === undefined ||
options.doc.content_type.indexOf("application/x-asc") === 0
});
})
.onEvent('submit', function () {
var gadget = this, doc;
var gadget = this, data;
return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
......@@ -39,14 +38,18 @@
return form_gadget.getContent();
})
.push(function (content) {
if (gadget.state.editable) {
data = content.text_content;
content.text_content = undefined;
return gadget.updateDocument(content);
})
.push(function () {
if (gadget.state.content_editable) {
return gadget.jio_putAttachment(
gadget.state.jio_key,
"data",
jIO.util.dataURItoBlob(content.text_content)
jIO.util.dataURItoBlob(data)
);
}
return gadget.updateDocument(content);
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
......@@ -80,7 +83,6 @@
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
var editable = gadget.state.editable && gadget.state.content_editable;
return form_gadget.render({
erp5_document: {
"_embedded": {"_view": {
......@@ -90,9 +92,9 @@
"default": gadget.state.doc.title,
"css_class": "",
"required": 1,
"editable": 1 - editable,
"editable": 1,
"key": "title",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_reference": {
......@@ -101,9 +103,9 @@
"default": gadget.state.doc.reference,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "reference",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_version": {
......@@ -112,9 +114,9 @@
"default": gadget.state.doc.version,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "version",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_language": {
......@@ -123,9 +125,9 @@
"default": gadget.state.doc.language,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "language",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_description": {
......@@ -134,19 +136,19 @@
"default": gadget.state.doc.description,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "description",
"hidden": editable,
"hidden": 0,
"type": "TextAreaField"
},
"my_content": {
"default": ((gadget.state.editable || !gadget.state.content_editable) ? data : ""),
"css_class": editable ? "content-iframe-maximize" : "",
"default": data,
"css_class": "",
"required": 0,
"editable": editable,
"editable": 1,
"key": "text_content",
"hidden": 0,
"type": editable ? "GadgetField" : "EditorField",
"type": gadget.state.content_editable ? "GadgetField" : "EditorField",
"url": "../ooffice_presentation_gadget/app/",
"sandbox": "iframe"
}
......@@ -173,26 +175,17 @@
return RSVP.all([
gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: 'selection_previous'}),
gadget.getUrlFor({command: 'selection_next'}),
gadget.getUrlFor({command: "change", options: {editable: true}})
gadget.getUrlFor({command: 'selection_next'})
]);
})
.push(function (url_list) {
var header_dict = {
return gadget.updateHeader({
page_title: gadget.state.doc.title,
selection_url: url_list[0],
previous_url: url_list[1],
next_url: url_list[2],
save_action: true
};
if (gadget.state.content_editable) {
if (gadget.state.editable) {
header_dict.edit_properties = url_list[3].replace("n.editable=true", "").replace("p.editable=true", "");
} else {
header_dict.edit_content = url_list[3];
}
}
return gadget.updateHeader(header_dict);
save_action: true,
previous_url : url_list[1],
next_url : url_list[2]
});
});
});
}(window, rJS, RSVP, jIO, Blob));
\ No newline at end of file
......@@ -233,7 +233,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.47399.35230.56951</string> </value>
<value> <string>964.5637.48492.53981</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -251,7 +251,7 @@
</tuple>
<state>
<tuple>
<float>1508245197.16</float>
<float>1513090920.75</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -23,14 +23,13 @@
return this.changeState({
jio_key: options.jio_key,
doc: options.doc,
editable: options.editable ? 1 : 0,
content_editable: options.doc.content_type === undefined ||
options.doc.content_type.indexOf("application/x-asc") === 0
});
})
.onEvent('submit', function () {
var gadget = this, doc;
var gadget = this, doc, data;
return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
......@@ -39,14 +38,18 @@
return form_gadget.getContent();
})
.push(function (content) {
if (gadget.state.editable) {
data = content.text_content;
content.text_content = undefined;
return gadget.updateDocument(content);
})
.push(function () {
if (gadget.state.content_editable) {
return gadget.jio_putAttachment(
gadget.state.jio_key,
"data",
jIO.util.dataURItoBlob(content.text_content)
jIO.util.dataURItoBlob(data)
);
}
return gadget.updateDocument(content);
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
......@@ -80,7 +83,6 @@
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
var editable = gadget.state.editable && gadget.state.content_editable;
return form_gadget.render({
erp5_document: {
"_embedded": {"_view": {
......@@ -90,9 +92,9 @@
"default": gadget.state.doc.title,
"css_class": "",
"required": 1,
"editable": 1 - editable,
"editable": 1,
"key": "title",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_reference": {
......@@ -101,9 +103,9 @@
"default": gadget.state.doc.reference,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "reference",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_version": {
......@@ -112,9 +114,9 @@
"default": gadget.state.doc.version,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "version",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_language": {
......@@ -123,9 +125,9 @@
"default": gadget.state.doc.language,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "language",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_description": {
......@@ -134,19 +136,19 @@
"default": gadget.state.doc.description,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "description",
"hidden": editable,
"hidden": 0,
"type": "TextAreaField"
},
"my_content": {
"default": gadget.state.editable || !gadget.state.content_editable ? data: "",
"css_class": editable ? "content-iframe-maximize" : "",
"default": data,
"css_class": "",
"required": 0,
"editable": editable,
"editable": 1,
"key": "text_content",
"hidden": 0,
"type": editable ? "GadgetField" : "EditorField",
"type": gadget.state.content_editable ? "GadgetField" : "EditorField",
"url": "../ooffice_spreadsheet_gadget/app/",
"sandbox": "iframe"
}
......@@ -173,26 +175,17 @@
return RSVP.all([
gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: 'selection_previous'}),
gadget.getUrlFor({command: 'selection_next'}),
gadget.getUrlFor({command: "change", options: {editable: true}})
gadget.getUrlFor({command: 'selection_next'})
]);
})
.push(function (url_list) {
var header_dict = {
return gadget.updateHeader({
page_title: gadget.state.doc.title,
selection_url: url_list[0],
previous_url: url_list[1],
next_url: url_list[2],
save_action: true
};
if (gadget.state.content_editable) {
if (gadget.state.editable) {
header_dict.edit_properties = url_list[3].replace("n.editable=true", "").replace("p.editable=true", "");
} else {
header_dict.edit_content = url_list[3];
}
}
return gadget.updateHeader(header_dict);
save_action: true,
previous_url : url_list[1],
next_url : url_list[2]
});
});
});
}(window, rJS, RSVP, jIO, Blob));
\ No newline at end of file
......@@ -233,7 +233,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.47399.35230.56951</string> </value>
<value> <string>964.5634.4854.39389</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -251,7 +251,7 @@
</tuple>
<state>
<tuple>
<float>1508245186.26</float>
<float>1513090896.91</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -23,14 +23,13 @@
return this.changeState({
jio_key: options.jio_key,
doc: options.doc,
editable: options.editable ? 1 : 0,
content_editable: options.doc.content_type === undefined ||
options.doc.content_type.indexOf("application/x-asc") === 0
});
})
.onEvent('submit', function () {
var gadget = this, doc;
var gadget = this, data;
return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
......@@ -39,14 +38,18 @@
return form_gadget.getContent();
})
.push(function (content) {
if (gadget.state.editable) {
data = content.text_content;
content.text_content = undefined;
return gadget.updateDocument(content);
})
.push(function () {
if (gadget.state.content_editable) {
return gadget.jio_putAttachment(
gadget.state.jio_key,
"data",
jIO.util.dataURItoBlob(content.text_content)
jIO.util.dataURItoBlob(data)
);
}
return gadget.updateDocument(content);
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
......@@ -80,7 +83,6 @@
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
var editable = gadget.state.editable && gadget.state.content_editable;
return form_gadget.render({
erp5_document: {
"_embedded": {"_view": {
......@@ -90,9 +92,9 @@
"default": gadget.state.doc.title,
"css_class": "",
"required": 1,
"editable": 1 - editable,
"editable": 1,
"key": "title",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_reference": {
......@@ -101,9 +103,9 @@
"default": gadget.state.doc.reference,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "reference",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_version": {
......@@ -112,9 +114,9 @@
"default": gadget.state.doc.version,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "version",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_language": {
......@@ -123,9 +125,9 @@
"default": gadget.state.doc.language,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "language",
"hidden": editable,
"hidden": 0,
"type": "StringField"
},
"my_description": {
......@@ -134,19 +136,19 @@
"default": gadget.state.doc.description,
"css_class": "",
"required": 0,
"editable": 1 - editable,
"editable": 1,
"key": "description",
"hidden": editable,
"hidden": 0,
"type": "TextAreaField"
},
"my_content": {
"default": gadget.state.editable || !gadget.state.content_editable ? data: "",
"css_class": editable ? "content-iframe-maximize" : "",
"default": data,
"css_class": "",
"required": 0,
"editable": editable,
"editable": 1,
"key": "text_content",
"hidden": 0,
"type": editable ? "GadgetField" : "EditorField",
"type": gadget.state.content_editable ? "GadgetField" : "EditorField",
"url": "../ooffice_text_gadget/app/",
"sandbox": "iframe"
}
......@@ -173,26 +175,17 @@
return RSVP.all([
gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: 'selection_previous'}),
gadget.getUrlFor({command: 'selection_next'}),
gadget.getUrlFor({command: "change", options: {editable: true}})
gadget.getUrlFor({command: 'selection_next'})
]);
})
.push(function (url_list) {
var header_dict = {
return gadget.updateHeader({
page_title: gadget.state.doc.title,
selection_url: url_list[0],
previous_url: url_list[1],
next_url: url_list[2],
save_action: true
};
if (gadget.state.content_editable) {
if (gadget.state.editable) {
header_dict.edit_properties = url_list[3].replace("n.editable=true", "").replace("p.editable=true", "");
} else {
header_dict.edit_content = url_list[3];
}
}
return gadget.updateHeader(header_dict);
save_action: true,
previous_url : url_list[1],
next_url : url_list[2]
});
});
});
}(window, rJS, RSVP, jIO, Blob));
\ No newline at end of file
......@@ -233,7 +233,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.47399.35230.56951</string> </value>
<value> <string>964.5637.7087.14148</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -251,7 +251,7 @@
</tuple>
<state>
<tuple>
<float>1508245173.46</float>
<float>1513090895.02</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment