024938411a8962b9f7f4b2d1ae56c4ea3a71b18d
[redakcja.git] / src / redakcja / static / js / wiki / dialog_pubmark.js
1 /*
2  * Dialog for marking document for publishing
3  *
4  */
5 (function($){
6
7     class PubmarkDialog extends $.wiki.cls.GenericDialog {
8         constructor(element, options) {
9             if (!options.revision  && options.revision != 0)
10                 throw "PubmarkDialog needs a revision number.";
11
12             super(element);
13             this.ctx = $.wiki.exitContext();
14             this.clearForm();
15
16             /* fill out hidden fields */
17             this.$form = $('form', element);
18
19             $("input[name='pubmark-id']", this.$form).val(CurrentDocument.id);
20             $("input[name='pubmark-revision']", this.$form).val(options.revision);
21
22         }
23
24         cancelAction() {
25             $.wiki.enterContext(this.ctx);
26             this.hide();
27         }
28
29         saveAction() {
30             var self = this;
31
32             self.$elem.block({
33                 message: "Oznaczanie wersji",
34                 fadeIn: 0,
35             });
36
37             CurrentDocument.pubmark({
38                 form: self.$form,
39                 success: function(doc, changed, info){
40                     self.$elem.block({
41                         message: info,
42                         timeout: 2000,
43                         fadeOut: 0,
44                         onUnblock: function(){
45                             self.hide();
46                             $.wiki.enterContext(self.ctx);
47                         }
48                     });
49                 },
50                 failure: function(doc, info){
51                     console.log("Failure", info);
52                     self.reportErrors(info);
53                     self.$elem.unblock();
54                 }
55             });
56         }
57     }
58
59     /* make it global */
60     $.wiki.cls.PubmarkDialog = PubmarkDialog;
61 })(jQuery);