Improved Upload form. * Closes #25.
h3rald h3rald@h3rald.com
Fri, 25 Sep 2015 22:16:57 +0200
3 files changed,
18 insertions(+),
9 deletions(-)
M
admin/js/components/document.js
→
admin/js/components/document.js
@@ -140,9 +140,7 @@ vm.viewDocument();
}); }; - var onFailure = function(data){ - vm.flashError; - }; + var onFailure = function(data) { vm.flashError(data); }; var modalId = u.guid();
M
admin/js/components/uploader.js
→
admin/js/components/uploader.js
@@ -46,23 +46,28 @@ doc.data = window.atob(doc.data);
} return Doc.put(doc, vm.file().type).then(args.onSuccess, args.onFailure); }; + + vm.cancel = function(){ + $("input:file").val(''); + }; + return vm; - } + }; app.uploader.view = function(ctrl, args){ var config = { title: "Upload Document", id: "upload-"+ctrl.id+"-modal", action: ctrl.save, + dismiss: ctrl.cancel, actionText: "Upload", - content: m("div", [ + content: m("div.upload-form", [ m(".form-group", [ m("label", "Document ID"), m("input.form-control", { placeholder: "Enter document ID", onchange: m.withAttr("value", ctrl.docid), size: 35, - disabled: (ctrl.docid() === "") ? false : true, value: ctrl.docid() }) ]),
M
admin/js/components/widgets.js
→
admin/js/components/widgets.js
@@ -101,7 +101,7 @@
/* DROPDOWN */ app.widgets.taglink = { view: function(ctrl, args) { - var color = /^\$/.test(args.name) ? "warning" : "primary" + var color = /^\$/.test(args.name) ? "warning" : "primary"; return m("span.tag-label.label.label-"+color, [m("i.fa.fa-tag"), " ", m("a", {href: "/tags/"+args.name, config:m.route}, args.name)]); }@@ -138,6 +138,12 @@
/* MODAL */ app.widgets.modal = { view: function(ctrl, args){ + if (!args.dismiss){ + args.dismiss = function(){}; + } + if (!args.dismissText) { + args.dismissText = "Close"; + } return m(".modal.fade", {id: args.id, tabindex: "-1", role: "dialog"}, [@@ -150,7 +156,7 @@ m("h4.modal-title", args.title)
]), m(".modal-body", [args.content]), m(".modal-footer", [ - m("button.btn.btn-default[data-dismiss='modal']", "Close"), + m("button.btn.btn-default[data-dismiss='modal']", {onclick: args.dismiss}, args.dismissText), m("button.btn.btn-primary[data-dismiss='modal']", {onclick: args.action}, args.actionText) ]) ])@@ -160,4 +166,4 @@ );
} }; -}()); +}());