outstanding translation
[fnpeditor.git] / src / editor / modules / data / data.js
index 0d556a2..54c4c17 100644 (file)
@@ -179,6 +179,12 @@ return function(sandbox) {
                     executeButtonText: gettext('Save'),
                     cancelButtonText: gettext('Cancel')
                 });
                     executeButtonText: gettext('Save'),
                     cancelButtonText: gettext('Cancel')
                 });
+            /* Set stage field initial value to current document stage. */
+            for (var i in documentSaveForm.fields) {
+                if (documentSaveForm.fields[i].name == 'textsave-stage') {
+                    documentSaveForm.fields[i].initialValue = data.stage;
+                }
+            }
             
             dialog.on('execute', function(event) {
                 sandbox.publish('savingStarted', 'remote');
             
             dialog.on('execute', function(event) {
                 sandbox.publish('savingStarted', 'remote');
@@ -209,7 +215,19 @@ return function(sandbox) {
 
                         reloadHistory();
                     },
 
                         reloadHistory();
                     },
-                    error: function() {event.error(); sandbox.publish('savingEnded', 'error', 'remote');}
+                    error: function(data) {
+                        event.error();
+                        sandbox.publish('savingEnded', 'error', 'remote');
+                        var dialog = Dialog.create({
+                            title: gettext('Error'),
+                            text: JSON.parse(data.responseText).text.join('\n'),
+                            executeButtonText: gettext('Close')
+                        });
+                        dialog.show();
+                        dialog.on('execute', function(e) {
+                            e.success();
+                        });
+                    }
                 });
             });
             dialog.on('cancel', function() {
                 });
             });
             dialog.on('cancel', function() {
@@ -275,6 +293,42 @@ return function(sandbox) {
             });
             dialog.show();
         },
             });
             dialog.show();
         },
+        publishVersion: function(revision) {
+            var documentPublishForm = $.extend({
+                        fields: [],
+                        revision_field_name: 'revision'
+                    },
+                    sandbox.getConfig().documentPublishForm
+                ),
+                dialog = Dialog.create({
+                    fields: documentPublishForm.fields,
+                    title: gettext('Publish'),
+                    executeButtonText: gettext('Publish'),
+                    cancelButtonText: gettext('Cancel')
+                });
+
+            dialog.on('execute', function(event) {
+                var formData = event.formData;
+                formData[documentPublishForm.revision_field_name] = revision;
+                sandbox.publish('publishingStarted', {version: revision});
+                if(sandbox.getConfig().jsonifySentData) {
+                    formData = JSON.stringify(formData);
+                }
+                $.ajax({
+                    method: 'post',
+                    //dataType: 'json',
+                    dataType: 'text',
+                    url: sandbox.getConfig().documentPublishUrl,
+                    data: formData,
+                    success: function(data) {
+                        reloadHistory();
+                        sandbox.publish('documentPublished');
+                        event.success();
+                    },
+                });
+            });
+            dialog.show();
+        },
         dropDraft: function() {
             logger.debug('Dropping a draft...');
             wlxmlDocument.loadXML(sandbox.getBootstrappedData().document);
         dropDraft: function() {
             logger.debug('Dropping a draft...');
             wlxmlDocument.loadXML(sandbox.getBootstrappedData().document);
@@ -285,4 +339,4 @@ return function(sandbox) {
     };
 };
 
     };
 };
 
-});
\ No newline at end of file
+});