fix selecting nodes with no text & allow deleting images
[fnpeditor.git] / src / editor / modules / data / data.js
index 0d556a2..67ab801 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');
@@ -275,6 +281,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 +327,4 @@ return function(sandbox) {
     };
 };
 
     };
 };
 
-});
\ No newline at end of file
+});