Updated management interface
authorThierry Florac <thierry.florac@onf.fr>
Thu, 21 Apr 2016 18:13:54 +0200
changeset 26 7f025cebf19d
parent 25 4f51a7d6e18d
child 27 be3984675d3f
Updated management interface
src/pyams_content/shared/news/zmi/properties.py
src/pyams_content/skin/resources/js/pyams_content.js
src/pyams_content/skin/resources/js/pyams_content.min.js
--- a/src/pyams_content/shared/news/zmi/properties.py	Thu Apr 21 18:13:29 2016 +0200
+++ b/src/pyams_content/shared/news/zmi/properties.py	Thu Apr 21 18:13:54 2016 +0200
@@ -21,10 +21,9 @@
 from pyams_skin.layer import IPyAMSLayer
 
 # import packages
-from pyams_content.shared.common.zmi.properties import SharedContentPropertiesEditForm, \
-    SharedContentPropertiesSummaryDisplayForm
+from pyams_content.shared.common.zmi.properties import SharedContentPropertiesEditForm
 from pyams_utils.adapter import adapter_config
-from pyams_zmi.form import InnerAdminEditForm, InnerAdminDisplayForm
+from pyams_zmi.form import InnerAdminEditForm
 from z3c.form import field
 
 from pyams_content import _
@@ -40,15 +39,3 @@
     fieldset_class = 'bordered no-x-margin margin-y-10'
 
     fields = field.Fields(IWfNewsEvent).select('displayed_publication_date', 'push_end_date')
-
-
-@adapter_config(name='publication-summary',
-                context=(IWfNewsEvent, IPyAMSLayer, SharedContentPropertiesSummaryDisplayForm),
-                provides=IInnerSubForm)
-class NewsEventPropertiesSummaryDisplayForm(InnerAdminDisplayForm):
-    """News event properties summary display form"""
-
-    legend = _("Publication settings")
-    fields = field.Fields(IWfNewsEvent).select('displayed_publication_date', 'push_end_date')
-
-    weight = 50
--- a/src/pyams_content/skin/resources/js/pyams_content.js	Thu Apr 21 18:13:29 2016 +0200
+++ b/src/pyams_content/skin/resources/js/pyams_content.js	Thu Apr 21 18:13:54 2016 +0200
@@ -72,7 +72,7 @@
 
 			refreshContainer: function(changes) {
 				var para = $('tr[data-ams-element-name="' + changes.object_name + '"]');
-				var counter = $('span.count', $('td.extfiles', para));
+				var counter = $('span.count', $('div.action.extfiles', para));
 				if (changes.nb_files > 0) {
 					counter.text('(' + changes.nb_files + ')');
 				} else {
@@ -106,7 +106,7 @@
 
 			refreshContainer: function(changes) {
 				var para = $('tr[data-ams-element-name="' + changes.object_name + '"]');
-				var counter = $('span.count', $('td.links', para));
+				var counter = $('span.count', $('div.action.links', para));
 				if (changes.nb_links > 0) {
 					counter.text('(' + changes.nb_links + ')');
 				} else {
@@ -173,7 +173,7 @@
 
 			refreshContainer: function(changes) {
 				var para = $('tr[data-ams-element-name="' + changes.object_name + '"]');
-				var counter = $('span.count', $('td.galleries', para));
+				var counter = $('span.count', $('div.action.galleries', para));
 				if (changes.nb_galleries > 0) {
 					counter.text('(' + changes.nb_galleries + ')');
 				} else {
@@ -251,7 +251,6 @@
 				var source = $(this);
 				var switcher = $('i', source);
 				var container = source.parents('table');
-				// TODO: afficher le curseur de la roue qui tourne !!
 				if (switcher.hasClass('fa-plus-square-o')) {
 					switcher.removeClass('fa-plus-square-o')
 							.addClass('fa-cog fa-spin');
@@ -352,7 +351,8 @@
 				break;
 			case 'galleries_container':
 				PyAMS_content.galleries.refreshContainer(settings);
-				break;		}
+				break;
+		}
 	});
 
 })(jQuery, this);
--- a/src/pyams_content/skin/resources/js/pyams_content.min.js	Thu Apr 21 18:13:29 2016 +0200
+++ b/src/pyams_content/skin/resources/js/pyams_content.min.js	Thu Apr 21 18:13:54 2016 +0200
@@ -1,1 +1,1 @@
-(function(b,a){var d=a.MyAMS;var c={TinyMCE:{initEditor:function(e){e.image_list=c.TinyMCE.getImagesList;e.link_list=c.TinyMCE.getLinksList;return e},getImagesList:function(e){return d.ajax.post("get-images-list.json",{},e)},getLinksList:function(e){return d.ajax.post("get-links-list.json",{},e)}},profile:{switchFavorite:function(){var f=b(this);var e=f.data("sequence-oid");d.ajax.post("switch-user-favorite.json",{oid:e},function(g,h){if(g.favorite){f.removeClass("fa-star-o").addClass("fa-star")}else{f.removeClass("fa-star").addClass("fa-star-o")}})}},extfiles:{refresh:function(f){if(typeof(f)==="string"){f=JSON.parse(f)}var e=b('select[name="form.widgets.files:list"]');var g=e.data("select2");b("<option></option>").attr("value",f.new_file.id).attr("selected","selected").text(f.new_file.text).appendTo(e);var h=e.select2("data");h.push(f.new_file);e.select2("data",h);g.results.empty();g.opts.populateResults.call(g,g.results,f.files,{term:""})},refreshContainer:function(g){var e=b('tr[data-ams-element-name="'+g.object_name+'"]');var f=b("span.count",b("td.extfiles",e));if(g.nb_files>0){f.text("("+g.nb_files+")")}else{f.text("")}}},links:{refresh:function(f){if(typeof(f)==="string"){f=JSON.parse(f)}var e=b('select[name="form.widgets.links:list"]');var g=e.data("select2");b("<option></option>").attr("value",f.new_link.id).attr("selected","selected").text(f.new_link.text).appendTo(e);var h=e.select2("data");h.push(f.new_link);e.select2("data",h);g.results.empty();g.opts.populateResults.call(g,g.results,f.links,{term:""})},refreshContainer:function(g){var e=b('tr[data-ams-element-name="'+g.object_name+'"]');var f=b("span.count",b("td.links",e));if(g.nb_links>0){f.text("("+g.nb_links+")")}else{f.text("")}}},galleries:{refresh:function(f){if(typeof(f)==="string"){f=JSON.parse(f)}var e=b('select[name="form.widgets.galleries:list"]');var g=e.data("select2");b("<option></option>").attr("value",f.new_gallery.id).attr("selected","selected").text(f.new_gallery.text).appendTo(e);var h=e.select2("data");h.push(f.new_gallery);e.select2("data",h);g.results.empty();g.opts.populateResults.call(g,g.results,f.galleries,{term:""})},setOrder:function(g,h){if(h&&h.item.hasClass("already-dropped")){return}var e=h.item.parents(".gallery");var f=b(".image",e).listattr("data-ams-element-name");d.ajax.post(e.data("ams-location")+"/set-images-order.json",{images:JSON.stringify(f)})},removeFile:function(e){return function(){var f=b(this);d.skin.bigBox({title:d.i18n.WARNING,content:'<i class="text-danger fa fa-2x fa-bell shake animated"></i>&nbsp; '+d.i18n.DELETE_WARNING,buttons:d.i18n.BTN_OK_CANCEL},function(j){if(j===d.i18n.BTN_OK){var i=f.parents(".gallery");var h=i.data("ams-location");var k=f.parents(".image");var g=k.data("ams-element-name");d.ajax.post(h+"/delete-element.json",{object_name:g},function(l,m){k.remove()})}})}},refreshContainer:function(g){var e=b('tr[data-ams-element-name="'+g.object_name+'"]');var f=b("span.count",b("td.galleries",e));if(g.nb_galleries>0){f.text("("+g.nb_galleries+")")}else{f.text("")}}},paragraphs:{switchVisibility:function(e){return function(){var h=b(this);var f=h.parents("tr");var g=f.parents("table");d.ajax.post(g.data("ams-location")+"/set-paragraph-visibility.json",{object_name:f.data("ams-element-name")},function(i,j){if(i.visible){b("i",h).attr("class","fa fa-fw fa-eye")}else{b("i",h).attr("class","fa fa-fw fa-eye-slash text-danger")}})}},refreshParagraph:function(g){var f=b('table[id="paragraphs_list"]');var e=b('tr[data-ams-element-name="'+g.object_name+'"]',f);if(g.visible){b("i",b("td.switcher",e)).removeClass("fa-eye-slash text-danger").addClass("fa-eye")}else{b("i",b("td.switcher",e)).removeClass("fa-eye").addClass("fa-eye-slash text-danger")}b("span.title",e).text(g.title||"--")},switchEditor:function(g){var j=b(this);var i=b("i",j);var k=j.parents("td");var h=b(".editor",k);var e=j.parents("tr");if(i.hasClass("fa-plus-square-o")){var f=e.parents("table");h.html('<h1 class="loading"><i class="fa fa-2x fa-gear fa-spin"></i></h1>');d.ajax.post(f.data("ams-location")+"/get-paragraph-editor.json",{object_name:e.data("ams-element-name")},function(l){h.html(l);if(l){d.initContent(h);i.removeClass("fa-plus-square-o").addClass("fa-minus-square-o");e.data("ams-disabled-handlers",true)}})}else{d.skin.cleanContainer(h);h.empty();i.removeClass("fa-minus-square-o").addClass("fa-plus-square-o");e.removeData("ams-disabled-handlers")}},switchAllEditors:function(f){var h=b(this);var g=b("i",h);var e=h.parents("table");if(g.hasClass("fa-plus-square-o")){g.removeClass("fa-plus-square-o").addClass("fa-cog fa-spin");d.ajax.post(e.data("ams-location")+"/get-paragraphs-editors.json",{},function(j){for(var k in j){if(!j.hasOwnProperty(k)){continue}var i=b('tr[data-ams-element-name="'+k+'"]',e);var l=b(".editor",i);if(l.is(":empty")){l.html(j[k]);d.initContent(l)}b(".fa-plus-square-o",i).removeClass("fa-plus-square-o").addClass("fa-minus-square-o");i.data("ams-disabled-handlers",true)}if(!b("i.fa-plus-square-o",b("tbody",e)).exists()){g.removeClass("fa-cog fa-spin").addClass("fa-minus-square-o")}})}else{b(".editor",e).each(function(){d.skin.cleanContainer(b(this));b(this).empty()});b(".fa-minus-square-o",e).removeClass("fa-minus-square-o").addClass("fa-plus-square-o");b("tr",e).removeData("ams-disabled-handlers")}}},themes:{initExtracts:function(g){var f=b('select[name="form.widgets.thesaurus_name:list"]',g);var e=f.val();var i=b('select[name="form.widgets.extract_name:list"]',g);var h=i.val();if(e){d.jsonrpc.post("getExtracts",{thesaurus_name:e},{url:"/api/thesaurus/json"},function(j){i.empty();b(j.result).each(function(){b("<option></option>").attr("value",this.id).attr("selected",this.id===h).text(this.text).appendTo(i)})})}i.attr("data-ams-events-handlers",'{"select2-open": "PyAMS_content.themes.getExtracts"}')},getExtracts:function(h){var e=b(h.currentTarget);var g=e.parents("form");var f=b('select[name="form.widgets.thesaurus_name:list"]',g).val();if(f){d.jsonrpc.post("getExtracts",{thesaurus_name:f},{url:"/api/thesaurus/json"},function(k){var j=b('select[name="form.widgets.extract_name:list"]',g);var i=j.data("select2");i.results.empty();i.opts.populateResults.call(i,i.results,k.result,{term:""})})}}}};a.PyAMS_content=c;b(a.document).on("PyAMS_content.changed_item",function(f,e){switch(e.object_type){case"paragraph":c.paragraphs.refreshParagraph(e);break;case"extfiles_container":c.extfiles.refreshContainer(e);break;case"links_container":c.links.refreshContainer(e);break;case"galleries_container":c.galleries.refreshContainer(e);break}})})(jQuery,this);
\ No newline at end of file
+(function(b,a){var d=a.MyAMS;var c={TinyMCE:{initEditor:function(e){e.image_list=c.TinyMCE.getImagesList;e.link_list=c.TinyMCE.getLinksList;return e},getImagesList:function(e){return d.ajax.post("get-images-list.json",{},e)},getLinksList:function(e){return d.ajax.post("get-links-list.json",{},e)}},profile:{switchFavorite:function(){var f=b(this);var e=f.data("sequence-oid");d.ajax.post("switch-user-favorite.json",{oid:e},function(g,h){if(g.favorite){f.removeClass("fa-star-o").addClass("fa-star")}else{f.removeClass("fa-star").addClass("fa-star-o")}})}},extfiles:{refresh:function(f){if(typeof(f)==="string"){f=JSON.parse(f)}var e=b('select[name="form.widgets.files:list"]');var g=e.data("select2");b("<option></option>").attr("value",f.new_file.id).attr("selected","selected").text(f.new_file.text).appendTo(e);var h=e.select2("data");h.push(f.new_file);e.select2("data",h);g.results.empty();g.opts.populateResults.call(g,g.results,f.files,{term:""})},refreshContainer:function(g){var e=b('tr[data-ams-element-name="'+g.object_name+'"]');var f=b("span.count",b("div.action.extfiles",e));if(g.nb_files>0){f.text("("+g.nb_files+")")}else{f.text("")}}},links:{refresh:function(f){if(typeof(f)==="string"){f=JSON.parse(f)}var e=b('select[name="form.widgets.links:list"]');var g=e.data("select2");b("<option></option>").attr("value",f.new_link.id).attr("selected","selected").text(f.new_link.text).appendTo(e);var h=e.select2("data");h.push(f.new_link);e.select2("data",h);g.results.empty();g.opts.populateResults.call(g,g.results,f.links,{term:""})},refreshContainer:function(g){var e=b('tr[data-ams-element-name="'+g.object_name+'"]');var f=b("span.count",b("div.action.links",e));if(g.nb_links>0){f.text("("+g.nb_links+")")}else{f.text("")}}},galleries:{refresh:function(f){if(typeof(f)==="string"){f=JSON.parse(f)}var e=b('select[name="form.widgets.galleries:list"]');var g=e.data("select2");b("<option></option>").attr("value",f.new_gallery.id).attr("selected","selected").text(f.new_gallery.text).appendTo(e);var h=e.select2("data");h.push(f.new_gallery);e.select2("data",h);g.results.empty();g.opts.populateResults.call(g,g.results,f.galleries,{term:""})},setOrder:function(g,h){if(h&&h.item.hasClass("already-dropped")){return}var e=h.item.parents(".gallery");var f=b(".image",e).listattr("data-ams-element-name");d.ajax.post(e.data("ams-location")+"/set-images-order.json",{images:JSON.stringify(f)})},removeFile:function(e){return function(){var f=b(this);d.skin.bigBox({title:d.i18n.WARNING,content:'<i class="text-danger fa fa-2x fa-bell shake animated"></i>&nbsp; '+d.i18n.DELETE_WARNING,buttons:d.i18n.BTN_OK_CANCEL},function(j){if(j===d.i18n.BTN_OK){var i=f.parents(".gallery");var h=i.data("ams-location");var k=f.parents(".image");var g=k.data("ams-element-name");d.ajax.post(h+"/delete-element.json",{object_name:g},function(l,m){k.remove()})}})}},refreshContainer:function(g){var e=b('tr[data-ams-element-name="'+g.object_name+'"]');var f=b("span.count",b("div.action.galleries",e));if(g.nb_galleries>0){f.text("("+g.nb_galleries+")")}else{f.text("")}}},paragraphs:{switchVisibility:function(e){return function(){var h=b(this);var f=h.parents("tr");var g=f.parents("table");d.ajax.post(g.data("ams-location")+"/set-paragraph-visibility.json",{object_name:f.data("ams-element-name")},function(i,j){if(i.visible){b("i",h).attr("class","fa fa-fw fa-eye")}else{b("i",h).attr("class","fa fa-fw fa-eye-slash text-danger")}})}},refreshParagraph:function(g){var f=b('table[id="paragraphs_list"]');var e=b('tr[data-ams-element-name="'+g.object_name+'"]',f);if(g.visible){b("i",b("td.switcher",e)).removeClass("fa-eye-slash text-danger").addClass("fa-eye")}else{b("i",b("td.switcher",e)).removeClass("fa-eye").addClass("fa-eye-slash text-danger")}b("span.title",e).text(g.title||"--")},switchEditor:function(g){var j=b(this);var i=b("i",j);var k=j.parents("td");var h=b(".editor",k);var e=j.parents("tr");if(i.hasClass("fa-plus-square-o")){var f=e.parents("table");h.html('<h1 class="loading"><i class="fa fa-2x fa-gear fa-spin"></i></h1>');d.ajax.post(f.data("ams-location")+"/get-paragraph-editor.json",{object_name:e.data("ams-element-name")},function(l){h.html(l);if(l){d.initContent(h);i.removeClass("fa-plus-square-o").addClass("fa-minus-square-o");e.data("ams-disabled-handlers",true)}})}else{d.skin.cleanContainer(h);h.empty();i.removeClass("fa-minus-square-o").addClass("fa-plus-square-o");e.removeData("ams-disabled-handlers")}},switchAllEditors:function(f){var h=b(this);var g=b("i",h);var e=h.parents("table");if(g.hasClass("fa-plus-square-o")){g.removeClass("fa-plus-square-o").addClass("fa-cog fa-spin");d.ajax.post(e.data("ams-location")+"/get-paragraphs-editors.json",{},function(j){for(var k in j){if(!j.hasOwnProperty(k)){continue}var i=b('tr[data-ams-element-name="'+k+'"]',e);var l=b(".editor",i);if(l.is(":empty")){l.html(j[k]);d.initContent(l)}b(".fa-plus-square-o",i).removeClass("fa-plus-square-o").addClass("fa-minus-square-o");i.data("ams-disabled-handlers",true)}if(!b("i.fa-plus-square-o",b("tbody",e)).exists()){g.removeClass("fa-cog fa-spin").addClass("fa-minus-square-o")}})}else{b(".editor",e).each(function(){d.skin.cleanContainer(b(this));b(this).empty()});b(".fa-minus-square-o",e).removeClass("fa-minus-square-o").addClass("fa-plus-square-o");b("tr",e).removeData("ams-disabled-handlers")}}},themes:{initExtracts:function(g){var f=b('select[name="form.widgets.thesaurus_name:list"]',g);var e=f.val();var i=b('select[name="form.widgets.extract_name:list"]',g);var h=i.val();if(e){d.jsonrpc.post("getExtracts",{thesaurus_name:e},{url:"/api/thesaurus/json"},function(j){i.empty();b(j.result).each(function(){b("<option></option>").attr("value",this.id).attr("selected",this.id===h).text(this.text).appendTo(i)})})}i.attr("data-ams-events-handlers",'{"select2-open": "PyAMS_content.themes.getExtracts"}')},getExtracts:function(h){var e=b(h.currentTarget);var g=e.parents("form");var f=b('select[name="form.widgets.thesaurus_name:list"]',g).val();if(f){d.jsonrpc.post("getExtracts",{thesaurus_name:f},{url:"/api/thesaurus/json"},function(k){var j=b('select[name="form.widgets.extract_name:list"]',g);var i=j.data("select2");i.results.empty();i.opts.populateResults.call(i,i.results,k.result,{term:""})})}}}};a.PyAMS_content=c;b(a.document).on("PyAMS_content.changed_item",function(f,e){switch(e.object_type){case"paragraph":c.paragraphs.refreshParagraph(e);break;case"extfiles_container":c.extfiles.refreshContainer(e);break;case"links_container":c.links.refreshContainer(e);break;case"galleries_container":c.galleries.refreshContainer(e);break}})})(jQuery,this);
\ No newline at end of file