text: /*! Cofoundry 2018-04-09 */
  angular.module("cms.customEntities",["ngRoute","cms.shared"]).constant("_",window._).constant("customEntities.modulePath","/Admin/Modules/CustomEntities/Js/"),angular.module("cms.customEntities").config(["$routeProvider","shared.routingUtilities","customEntities.modulePath",function(a,b,c){b.registerCrudRoutes(a,c,"CustomEntity")}]),angular.module("cms.customEntities").controller("AddCustomEntityController",["$scope","$location","$q","$window","shared.stringUtilities","shared.LoadState","shared.customEntityService","shared.urlLibrary","customEntities.options",function(a,b,c,d,e,f,g,h,i){function j(){s.globalLoadState=new f,s.saveLoadState=new f,s.saveAndPublishLoadState=new f,s.formLoadState=new f(!0),s.editMode=!1,s.options=i,s.saveButtonText=i.autoPublish?"Save":"Save & Publish",s.saveAndEditButtonText=i.autoPublish?"Save & Edit Content":"Save Draft & Edit Content",s.save=k.bind(null,!1,n),s.saveAndPublish=k.bind(null,!0,n),s.saveAndEdit=k.bind(null,!1,o),s.cancel=m,s.onNameChanged=l,p()}function k(a,b){var c;a?(s.command.publish=!0,c=s.saveAndPublishLoadState):c=s.saveLoadState,q(c),g.add(s.command,i.customEntityDefinitionCode).then(b)["finally"](r.bind(null,c))}function l(){s.command.urlSlug=e.slugify(s.command.title)}function m(){b.path("/")}function n(a){b.path("/"+a)}function o(a){function b(a){d.location.href=h.customEntityVisualEditor(a,!0)}return g.getById(a).then(b)}function p(){function b(a){s.command.model={},s.formDataSource={model:s.command.model,modelMetaData:a}}function c(a){s.pageRoutes=a}var d=g.getDataModelSchema(i.customEntityDefinitionCode).then(b),e=g.getPageRoutes(i.customEntityDefinitionCode).then(c);s.formLoadState.offWhen(d,e),s.command={},a.$watch("vm.command.localeId",function(a){a?s.additionalParameters={localeId:a}:s.additionalParameters={}})}function q(a){s.globalLoadState.on(),a&&_.isFunction(a.on)&&a.on()}function r(a){s.globalLoadState.off(),a&&_.isFunction(a.off)&&a.off()}var s=this;j()}]),angular.module("cms.customEntities").controller("CustomEntityDetailsController",["$routeParams","$q","$location","_","shared.LoadState","shared.modalDialogService","shared.entityVersionModalDialogService","shared.customEntityService","shared.urlLibrary","shared.permissionValidationService","customEntities.modulePath","customEntities.options",function(a,b,c,d,e,f,g,h,i,j,k,l){function m(){F.edit=n,F.save=o.bind(null,!1),F.saveAndPublish=o.bind(null,!0),F.cancel=p,F.publish=q,F.unpublish=r,F.discardDraft=s,F.copyToDraft=t,F.deleteCustomEntity=u,F.changeUrl=v,F.editMode=!1,F.globalLoadState=new e,F.saveLoadState=new e,F.saveAndPublishLoadState=new e,F.formLoadState=new e(!0),F.options=l,F.urlLibrary=i,F.saveButtonText=l.autoPublish?"Save":"Save & Publish",F.canChangeUrl=!l.autoGenerateUrlSlug||l.hasLocale,F.canPublish=w("CMEPUB"),F.canUpdateUrl=w("UPDURL"),F.canDelete=w("COMDEL"),F.canUpdate=w("CMEPUB"),z(F.formLoadState)}function n(){F.editMode=!0,F.mainForm.formStatus.clear()}function o(a){var b;a?(F.updateCommand.publish=!0,b=F.saveAndPublishLoadState):b=F.saveLoadState,C(b),h.updateDraft(F.updateCommand,l.customEntityDefinitionCode).then(x.bind(null,"Changes were saved successfully"))["finally"](D.bind(null,b))}function p(){F.editMode=!1,F.updateCommand=A(F.customEntity),F.mainForm.formStatus.clear()}function q(){g.publish(F.customEntity.customEntityId,C,H).then(x.bind(null,l.nameSingular+" published successfully."))["catch"](D)}function r(){g.unpublish(F.customEntity.customEntityId,C,H).then(x.bind(null,"The "+G+" has been unpublished and reverted to draft state."))["catch"](D)}function s(){function a(){return C(),h.removeDraft(F.customEntity.customEntityId)}var b={title:"Discard Version",message:"Are you sure you want to discard this draft? This will discard all changes since it was last published.",okButtonTitle:"Yes, discard it",onOk:a};f.confirm(b).then(x.bind(null,"Draft discarded successfully"))}function t(a){function b(){x("Draft created successfully.")}var c=!!y();g.copyToDraft(F.customEntity.customEntityId,a.customEntityVersionId,c,C,H).then(b)["catch"](D)}function u(){function a(){return C(),h.remove(F.customEntity.customEntityId).then(B)["catch"](D)}var b={title:"Delete "+l.nameSingular,message:"Are you sure you want to delete this "+G+"?",okButtonTitle:"Yes, delete it",onOk:a};f.confirm(b)}function v(){f.show({templateUrl:k+"Routes/Modals/ChangeUrl.html",controller:"ChangeUrlController",options:{customEntity:F.customEntity,onSave:x.bind(null,"Url Changed")}})}function w(a){return j.hasPermission(l.customEntityDefinitionCode+a)}function x(a,b){return z(b).then(F.mainForm.formStatus.success.bind(null,a))}function y(){return d.find(F.versions,function(a){return"Draft"===a.workFlowStatus})}function z(c){function d(a){var b=a[0],c=a[1];E=a[2],F.customEntity=b,F.versions=c,F.updateCommand=A(b),F.isMarkedPublished="Published"==F.customEntity.publishStatus,F.customEntity.locale?F.additionalParameters={localeId:F.customEntity.locale.localeId}:F.additionalParameters={},F.editMode=!1}function e(){return h.getDataModelSchema(l.customEntityDefinitionCode)}function f(){return h.getById(a.id)}function g(){return h.getVersionsByCustomEntityId(a.id)}return b.all([f(),g(),e()]).then(d).then(D.bind(null,c))}function A(a){var b={customEntityId:a.customEntityId,title:a.latestVersion.title,model:angular.copy(a.latestVersion.model)};return F.formDataSource={model:b.model,modelMetaData:E},b}function B(){c.path("")}function C(a){F.globalLoadState.on(),a&&d.isFunction(a.on)&&a.on()}function D(a){F.globalLoadState.off(),a&&d.isFunction(a.off)&&a.off()}var E,F=this,G=l.nameSingular.toLowerCase(),H={entityNameSingular:l.nameSingular,isCustomEntity:!0};m()}]),angular.module("cms.customEntities").controller("CustomEntityListController",["$q","_","shared.LoadState","shared.SearchQuery","shared.modalDialogService","shared.customEntityService","shared.permissionValidationService","shared.ModelPreviewFieldset","shared.ImagePreviewFieldCollection","customEntities.modulePath","customEntities.options",function(a,b,c,d,e,f,g,h,i,j,k){function l(){r.options=k,r.gridLoadState=new c,r.query=new d({onChanged:o}),r.filter=r.query.getFilters(),r.toggleFilter=m,r.changeOrdering=n,r.permissions=g,r.canUpdate=p("COMUPD"),r.canCreate=p("COMCRT"),m(!1),q()}function m(a){r.isFilterVisible=b.isUndefined(a)?!r.isFilterVisible:a}function n(){e.show({templateUrl:j+"Routes/Modals/ChangeOrdering.html",controller:"ChangeOrderingController",options:{localeId:r.filter.localeId,onSave:q}})}function o(){m(!1),q()}function p(a){return g.hasPermission(k.customEntityDefinitionCode+a)}function q(){function b(){return r.gridLoadState.on(),f.getAll(r.query.getParameters(),k.customEntityDefinitionCode).then(function(a){r.result=a,r.gridLoadState.off()})}function c(){return f.getDataModelSchema(k.customEntityDefinitionCode)}function d(a){r.previewFields=new h(a)}function e(){return r.gridImages=new i,r.gridImages.load(r.result.items,r.previewFields)}var g,j=b();return r.previewFields?(g=a.defer(),g.resolve()):g=c().then(d),a.all([g,j]).then(e)}var r=this;l()}]),angular.module("cms.customEntities").controller("ChangeOrderingController",["$scope","$q","$location","_","shared.LoadState","shared.arrayUtilities","shared.internalModulePath","shared.modalDialogService","shared.customEntityService","customEntities.options","options","close",function(a,b,c,d,e,f,g,h,i,j,k,l){function m(){a.options=j,a.command={localeId:k.localeId,customEntityDefinitionCode:j.customEntityDefinitionCode},a.isPartialOrdering="Partial"===j.ordering,a.submitLoadState=new e,a.formLoadState=new e(!0),a.gridLoadState=new e,a.save=n,a.close=l,a.setStep=u,a.onLocalesLoaded=o,a.onDrop=p,a.remove=q,a.showPicker=r,t()}function n(){a.command.orderedCustomEntityIds=s(),a.submitLoadState.on(),i.updateOrdering(a.command).then(k.onSave).then(l)["finally"](a.submitLoadState.off)}function o(){a.formLoadState.off()}function p(b,c){f.moveObject(a.gridData,c,b,w)}function q(b){f.removeObject(a.gridData,b)}function r(){function b(b){if(b&&b.length){var c=d.filter(a.gridData,function(a){return!d.contains(b,a[w])});a.gridData=d.difference(a.gridData,c);var e=d.difference(b,s());e.length&&(a.gridLoadState.on(),i.getByIdRange(e).then(function(b){a.gridData=d.union(a.gridData,b),a.gridLoadState.off()}))}else a.gridData=[]}h.show({templateUrl:g+"UIComponents/CustomEntities/CustomEntityPickerDialog.html",controller:"CustomEntityPickerDialogController",options:{selectedIds:s(),customEntityDefinition:j,filter:{localeId:a.command.localeId},onSelected:b}})}function s(){return d.pluck(a.gridData,w)}function t(){j.hasLocale?(a.allowStep1=!0,u(1)):(u(2),a.formLoadState.off())}function u(b){a.currentStep=b,2===b&&v()}function v(){function b(b){a.isPartialOrdering?a.gridData=d.filter(b.items,function(a){return!!a.ordering}):a.gridData=b.items,a.formLoadState.off()}a.formLoadState.on();var c={pageSize:60,localeId:a.command.localeId,interpretNullLocaleAsNone:!0};i.getAll(c,j.customEntityDefinitionCode).then(b)}var w="customEntityId";m()}]),angular.module("cms.customEntities").controller("ChangeUrlController",["$scope","$q","$location","shared.LoadState","shared.customEntityService","customEntities.options","options","close",function(a,b,c,d,e,f,g,h){function i(){var b=g.customEntity;a.options=f,a.customEntity=b,a.command={customEntityId:b.customEntityId,localeId:b.locale?b.locale.localeId:void 0,urlSlug:b.urlSlug},a.submitLoadState=new d,a.formLoadState=new d(f.hasLocale),a.save=j,a.close=h,a.localesLoaded=k.resolve,a.formLoadState.offWhen(k)}function j(){a.submitLoadState.on(),e.updateUrl(a.command).then(g.onSave).then(h)["finally"](a.submitLoadState.off)}var k=b.defer();i()}]);