tao-test/app/taoBackOffice/views/js/loader/taoBackOffice.min.js

2 lines
9.0 KiB
JavaScript
Raw Normal View History

2022-08-29 20:14:13 +02:00
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
//# sourceMappingURL=taoBackOffice.min.js.map