2 lines
9.0 KiB
JavaScript
2 lines
9.0 KiB
JavaScript
define("css!taoBackOfficeCss/list",[],function(){}),define("taoBackOffice/controller/list/index",["jquery","i18n","uri","util/url","ui/feedback","ui/dialog/confirm","layout/section","css!taoBackOfficeCss/list"],function($,__,Uri,urlUtil,feedback,dialogConfirm,section){'use strict';function findListContainer(uri){return $("#list-data_".concat(uri))}function clearUri(value){return value.replace(/^list-element_[0-9]+_/,"")}function createEditUriCheckbox(id){var $checkbox=$("<input>").attr("type","checkbox").attr("id",id).change(handleEditCheckboxStateChange),$label=$("<label>").attr("for",id).text(__("Edit URI"));return $("<span>").addClass("lft edit-uri").append($checkbox,$label)}function addSquareBtn(title,icon,$listToolBar){var position=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"rgt",$btn=$("<button>",{class:"btn-info small ".concat(position," icon-").concat(icon),title:__(title)});return $listToolBar.append($btn),$btn}function transformListElement($element){return createListElement($element.attr("id"),$element.text())}function createNewListElement(elementId){return createListElement("list-element_".concat(elementId,"_"))}function createListElement(name){var value=1<arguments.length&&arguments[1]!==void 0?arguments[1]:"";return $("<div class='list-element'>\n <div class='list-element'>\n <div class='list-element__input-container'>\n <input type='text' name='".concat(name,"' value='").concat(value,"' />\n <div class='list-element__input-container__uri'>\n <label for='uri_").concat(name,"' class='title'>URI</label>\n <input id='uri_").concat(name,"' type='text' name='uri_").concat(name,"' value='").concat(Uri.decode(clearUri(name)),"'>\n </div>\n </div>\n <span class='icon-checkbox-crossed list-element-delete-btn'>\n </div>\n </div>"))}function handleEditCheckboxStateChange(){findListContainer($(this).attr("id")).toggleClass("with-uri")}return{start:function start(){var saveUrl=urlUtil.route("saveLists","Lists","taoBackOffice"),delListUrl=urlUtil.route("removeList","Lists","taoBackOffice"),reloadListUrl=urlUtil.route("reloadRemoteList","Lists","taoBackOffice"),delEltUrl=urlUtil.route("removeListElement","Lists","taoBackOffice");$(".list-edit-btn").click(function(){var $listSaveBtn,$listNewBtn,uri=$(this).data("uri"),$listContainer=findListContainer(uri),$listForm=$listContainer.find("form"),$listTitleBar=$listContainer.find(".container-title h6"),$listToolBar=$listContainer.find(".data-container-footer").empty();if(!$listForm.length){var nextElementId;$listForm=$("<form>"),$listContainer.wrapInner($listForm),$listContainer.find("form").append("<input type='hidden' name='uri' value='".concat(uri,"' />"));var $labelEdit=$("<input type='text' name='label' value=''/>").val($listTitleBar.text());$listTitleBar.closest(".container-title").html($labelEdit),nextElementId=$listContainer.find(".list-element").replaceWith(function(){return transformListElement($(this))}).length,$listSaveBtn=addSquareBtn(__("Save list"),"save",$listToolBar),$listSaveBtn.on("click",function(){return $.postJson(saveUrl,$(this).closest("form").serializeArray(),function(response){if(response.saved)feedback().success(__("List saved")),section.get("taoBo_list").loadContentBlock(urlUtil.route("index","Lists","taoBackOffice"));else{var errors=(response.errors||[]).length?"<ul><li>".concat(response.errors.join("</li><li>"),"</li></ul>"):"";feedback().error("".concat(__("List not saved")).concat(errors),{encodeHtml:!1})}}),!1}),$listNewBtn=addSquareBtn("New element","add",$listToolBar),$listNewBtn.click(function(){var $list=$(this).closest("form").find("ol");return $list.append($("<li>").append(createNewListElement(nextElementId++))).closest(".container-content").scrollTop($list.height()),!1}),$listToolBar.append(createEditUriCheckbox(uri)),$listToolBar.append()}$listContainer.on("click",".list-element-delete-btn",function(){var $element=$(this).closest("li"),$input=$element.find("input:text"),eltUri=clearUri($input.attr("name")),deleteLocalElement=function(){$element.remove(),feedback().success(__("Element deleted"))},deleteServerAndLocalElement=function(){$.postJson(delEltUrl,{uri:eltUri},function(response){response.deleted?deleteLocalElement():feedback().error(__("Element not deleted"))})},deleteElement=function(){eltUri?deleteServerAndLocalElement():deleteLocalElement()};""===$input.val()?deleteElement():dialogConfirm(__("Please confirm you want to delete this list element."),deleteElement)})}),$(".list-delete-btn").click(function(){var $btn=$(this);dialogConfirm(__("Please confirm you want to delete this list. This operation cannot be undone."),function(){var uri=$btn.data("uri"),$list=$btn.parents(".data-container");$.postJson(delListUrl,{uri:uri},function(response){response.deleted?(feedback().success(__("List deleted")),$list.remove()):feedback().error(__("List not deleted"))})})}),$(".list-reload-btn").click(function(){var uri=$(this).data("uri");$.postJson(reloadListUrl,{uri:uri},function(response){response.saved?(feedback().success(__("List reloaded")),section.get("taoBo_remotelist").loadContentBlock(urlUtil.route("remote","Lists","taoBackOffice"))):feedback().error(__("List failed to be reloaded"))})})}}}),define("taoBackOffice/controller/routes",[],function(){'use strict';return{Lists:{actions:{index:"controller/list/index",remote:"controller/list/index"}},Trees:{actions:{viewTree:"controller/tree/view"}}}}),define("taoBackOffice/treeRender",["jquery","lodash","taoBackOffice/lib/vis/vis","css!taoBackOffice/lib/vis/vis"],function($,_,vis){'use strict';function destroy(){null!==network&&(network.destroy(),network=null)}var network=null,treeContainer=null,settings=null,data=null;return{init:function init(container,treeData,options){if(!container instanceof Element)throw new TypeError("tree container must be specified");treeContainer=container,options=options||{},treeData=treeData||{nodes:[],edges:[]},settings={layout:{hierarchical:{sortMethod:"directed",levelSeparation:200}},nodes:{shape:"box",color:{border:"#222",background:"#f2f0ee",highlight:{border:"#222",background:"#f2f0ee"}},font:{face:"'Franklin Gothic', 'Franklin Gothic Medium', 'Source Sans Pro', sans-serif",color:"#222"}},edges:{smooth:!1,width:.2,color:{color:"#222"},arrows:{to:!0},physics:!1,scaling:{label:!1}}},$.extend(settings,options),data={nodes:treeData.nodes?treeData.nodes:[],edges:treeData.edges?treeData.edges:[]}},run:function run(){destroy(),network=new vis.Network(treeContainer,data,settings),network.once("initRedraw",function(){100<data.nodes.length&&(network.setOptions($.extend(settings,{physics:{hierarchicalRepulsion:{nodeDistance:200},stabilization:{fit:!1}}})),network.fit({nodes:[data.nodes[0].id,data.nodes[1].id],animation:{duration:400,easingFunction:"linear"}}))})}}}),define("taoBackOffice/controller/tree/view",["layout/actions/binder","uri","jquery","context","helpers","taoBackOffice/treeRender"],function(binder,uri,$,context,helpers,treeRender){'use strict';return{start:function start(){$(".tree-container").each(function(i,obj){var $container=$(obj),uri=$container.data("id");$.post(helpers._url("getTree","Trees","taoBackOffice"),{uri:uri},function(treeData){var $parent=$container.closest(".content-block"),resizeContainer=function(){$container.height($parent.height()-$parent.find(".panel").eq(0).outerHeight()),$container.width($parent.width())};$(window).on("resize",resizeContainer),resizeContainer(),treeRender.init($container[0],treeData),treeRender.run()})})}}}),function(c){var d=document,s=d.createElement("style");s.type="text/css",d.getElementsByTagName("head")[0].appendChild(s),s.styleSheet?s.styleSheet.cssText=c:s.appendChild(d.createTextNode(c))}(".list-container .container-content .list-element{display:flex;width:100%}.list-container .container-content .list-element-delete-btn{font-size:2em;cursor:pointer;margin-left:4px}.list-container .container-content .list-element__input-container{flex:1}.list-container .container-content .list-element__input-container__uri{display:none;align-items:center;margin-top:2px;margin-bottom:10px;background:#e1e2e3}.list-container .container-content .list-element .title{color:#222;border:1px #ccc solid;border-top-left-radius:2px;border-bottom-left-radius:2px;margin:0;padding:3px}.list-container .container-content .list-element .title ~ input{border-top-left-radius:0;border-bottom-left-radius:0;border-left:none}.list-container .container-content .list-element input{width:100%}.list-container .edit-uri{display:flex;color:initial;font-family:\"Source Sans Pro\",sans-serif}.section-container .content-block .data-container-wrapper .list-container form{background-color:#f3f1ef}.section-container .content-block .data-container-wrapper .list-container form .data-container-footer{border-top:0 !important}.with-uri .container-content .list-element__input-container__uri{display:flex}\n\n/*# sourceMappingURL=../../../taoBackOffice/views/css/list.css.map */"),define("taoBackOffice/loader/taoBackOffice.bundle",function(){});
|
|
//# sourceMappingURL=taoBackOffice.min.js.map
|