Fix error with revision check during saving.
[redakcja.git] / src / redakcja / static / js / wiki / dialog_pubmark.js
old mode 100755 (executable)
new mode 100644 (file)
index 902a737..7d0126e
@@ -4,29 +4,34 @@
  */
 (function($){
 
  */
 (function($){
 
-    function PubmarkDialog(element, options){
-        if (!options.revision  && options.revision != 0)
-            throw "PubmarkDialog needs a revision number.";
+    class PubmarkDialog extends $.wiki.cls.GenericDialog {
+        constructor(element, options) {
+            if (!options.revision  && options.revision != 0)
+                throw "PubmarkDialog needs a revision number.";
 
 
-        this.ctx = $.wiki.exitContext();
-        this.clearForm();
+            let ctx = $.wiki.exitContext();
+            super(element);
+            this.ctx = ctx;
+            this.clearForm();
 
 
-        /* fill out hidden fields */
-        this.$form = $('form', element);
+            /* fill out hidden fields */
+            this.$form = $('form', element);
 
 
-        $("input[name='pubmark-id']", this.$form).val(CurrentDocument.id);
-        $("input[name='pubmark-revision']", this.$form).val(options.revision);
-
-        $.wiki.cls.GenericDialog.call(this, element);
-    };
+            $("input[name='pubmark-id']", this.$form).val(CurrentDocument.id);
+            $("input[name='pubmark-revision']", this.$form).val(options.revision);
+            if (options.approved) {
+                $("input[name='pubmark-publishable']", this.$form).prop('checked');
+            } else {
+                $("input[name='pubmark-publishable']", this.$form).removeProp('checked');
+            }
+        }
 
 
-    PubmarkDialog.prototype = $.extend(new $.wiki.cls.GenericDialog(), {
-        cancelAction: function(){
+        cancelAction() {
             $.wiki.enterContext(this.ctx);
             this.hide();
             $.wiki.enterContext(this.ctx);
             this.hide();
-        },
+        }
 
 
-        saveAction: function(){
+        saveAction() {
             var self = this;
 
             self.$elem.block({
             var self = this;
 
             self.$elem.block({
@@ -54,7 +59,7 @@
                 }
             });
         }
                 }
             });
         }
-    });
+    }
 
     /* make it global */
     $.wiki.cls.PubmarkDialog = PubmarkDialog;
 
     /* make it global */
     $.wiki.cls.PubmarkDialog = PubmarkDialog;