Index: cats/SCHEMAcat/trunk/urn.org.isocat.schemacat.site/site/scripts/controllers.js
===================================================================
--- cats/SCHEMAcat/trunk/urn.org.isocat.schemacat.site/site/scripts/controllers.js	(revision 4580)
+++ cats/SCHEMAcat/trunk/urn.org.isocat.schemacat.site/site/scripts/controllers.js	(revision 4581)
@@ -105,5 +105,5 @@
                     parentScope.filesList = prepareArrayForNgRepeat(result['sc:schema']['sc:files']['sc:file']);
                     parentScope.selectedSchema = fixEmptyFields(result);
-                    parentScope.schemaEditable = UserService.id === getSchemaOwnerID();
+                    parentScope.schemaEditable = UserService.id === getSchemaOwnerID() || UserService.roles.indexOf('admin') !== -1;
                     parentScope.resultHasArrived = true;
 
Index: cats/SCHEMAcat/trunk/urn.org.isocat.schemacat.site/site/scripts/controllers.min.js
===================================================================
--- cats/SCHEMAcat/trunk/urn.org.isocat.schemacat.site/site/scripts/controllers.min.js	(revision 4580)
+++ cats/SCHEMAcat/trunk/urn.org.isocat.schemacat.site/site/scripts/controllers.min.js	(revision 4581)
@@ -1,1 +1,1 @@
-"use strict";function prepareArrayForNgRepeat(e){var t;if(e instanceof Array)t=e;else t=new Array(e);return t}function isEmptyObj(e){if(e instanceof Object){for(var t in e){if(e.hasOwnProperty(t))return false}return true}else return false}function fixEmptyFields(e){if(isEmptyObj(e))return"";for(var t in e){if(e.hasOwnProperty(t)){if(isEmptyObj(e[t]))e[t]="";else if(e[t]instanceof Object)fixEmptyFields(e[t])}}return e}SCHEMAcat.controller("WorkspaceCtrl",["$scope","$location","$routeParams","$timeout","SchemasList","Schema","UserService","Settings",function(e,t,n,r,i,s,o,u){function a(n){if(isNaN(parseInt(n,10))||n<1){t.path("workspace/page/"+1+"/").search({schemaIndex:0});return}i.get({userID:o.id,startPage:n,pageSize:e.pageSize},function(r){if(n>Math.ceil(r["sc:result"]["sc:total-schemas"]/e.pageSize)){t.path("workspace/page/"+1+"/").search({schemaIndex:0});return}m.totalSchemaItems=r["sc:result"]["sc:total-schemas"];m.currentPage=Number(n);m.schemasList=prepareArrayForNgRepeat(r["sc:result"]["sc:schemas"]["sc:schema"]);f(t.search().schemaIndex);m.schemasResult=fixEmptyFields(r)})}function f(n){if(e.animateWorkspacePageChange!=="invisible")e.animateSchemaChange="invisible";if(isNaN(parseInt(n,10))||n<0||n>e.schemasList.length-1){e.selectedSchemaIndex=undefined;t.search({schemaIndex:0});return}e.selectedSchemaIndex=n;var r=m.schemasList[Number(n)];s.get({schemaID:r["xml:id"]},function(t){m.filesList=prepareArrayForNgRepeat(t["sc:schema"]["sc:files"]["sc:file"]);m.selectedSchema=fixEmptyFields(t);m.schemaEditable=o.id===l();m.resultHasArrived=true;if(u.getAnimationStatus()){switch(e.toNextSchema){case true:e.animateSchemaChange="animated fadeInUp";break;case false:e.animateSchemaChange="animated fadeInDown";break;case undefined:e.animateSchemaChange="animated fadeInDown"}}else e.animateSchemaChange=""})}function l(){var e;var t=prepareArrayForNgRepeat(m.selectedSchema["sc:schema"]["sc:access"]["sc:user"]);for(var n in t){if(t[n].role==="owner")e=t[n].ref}return e}function c(){e.workspace.namePanel.updateEditingName();e.workspace.descriptionPanel.updateEditingDescription();h()}function h(){var e=false;for(var n in g){if(t.search().hasOwnProperty(g[n])){v(n);e=true}}if(!e){p("")}}function p(t){for(var n in e.workspace.collapsibleDetailPanels){if(n!==t){e.workspace.collapsibleDetailPanels[n].detailButtonTooltip="Show field details";if(e.workspace.collapsibleDetailPanels[n].open===true){d(n);return true}}}return false}function d(t){if(e.workspace.collapsibleDetailPanels[t].editForm&&e.workspace.collapsibleDetailPanels[t].editForm.$dirty||e.workspace.collapsibleDetailPanels[t].modelDirty)e.workspace.collapsibleDetailPanels[t].detailButtonTooltip+=" (there are unsaved changes in this field!)";e.workspace.collapsibleDetailPanels[t].open=false}function v(t){function n(t){if(e.workspace.collapsibleDetailPanels[t]!==undefined&&e.workspace.collapsibleDetailPanels[t].updateEditPanel!==undefined)e.workspace.collapsibleDetailPanels[t].updateEditPanel();e.workspace.collapsibleDetailPanels[t].detailButtonTooltip="Hide field details";e.workspace.collapsibleDetailPanels[t].open=true}if(g.hasOwnProperty(t)){if(p(t)){r(function(){n(t)},350)}else n(t)}}var m=e.$parent;m.pageSize=10;var g={version:"showVersionDetails",status:"showStatusDetails",access:"showAccessDetails",license:"showLicenseDetails"};e.selectedSchemaIndex=n.schemaIndex;e.animateWorkspacePageChange="invisible";e.workspace={};e.location=location;if(!m.workspaceFullyLoaded)a(n.pageNumber);e.selectPage=function(e){t.search().schemaIndex="0";delete t.search().show;t.path("workspace.html/page/"+e+"/").search(t.search())};e.selectSchema=function(e){t.search().schemaIndex=e.toString();delete t.search().show;t.search(t.search())};e.toggleDetailsPanel=function(e){var n=g[e];if(t.search()[n]){delete t.search()[n]}else{for(var r in g){if(g[r]!==n)delete t.search()[g[r]]}t.search()[g[e]]=true}t.search(t.search())};e.$on("$routeChangeStart",function(t,n,r){m.resultHasArrived=false;if(u.getAnimationStatus()){if(n.params!==undefined&&n.params.pageNumber!==undefined&&n.params.pageNumber>r.params.pageNumber)m.toNextPage=true;else m.toNextPage=false;switch(n.templateUrl){case"partials/workspace.html":e.animateWorkspacePageChange=m.toNextPage?"animated slideOutLeft":"animated slideOutRight";break;case"partials/contact.html":case"partials/about.html":e.animateWorkspacePageChange="animated slideOutLeft";break;default:e.animateWorkspacePageChange="animated fadeOutDown"}}if(n.templateUrl==="partials/workspace.html")a(n.params.pageNumber);else m.workspaceFullyLoaded=false});e.$on("$routeChangeSuccess",function(e,t,n){if(u.getAnimationStatus()){if(n===undefined||n.templateUrl===undefined||n.templateUrl==="partials/accountDetails.html")m.toNextPage=undefined}});e.$on("$routeUpdate",function(t,n){if(n.templateUrl==="partials/workspace.html"&&n.params.schemaIndex!==e.selectedSchemaIndex){m.resultHasArrived=false;if(u.getAnimationStatus()){e.toNextSchema=n.params.schemaIndex>e.selectedSchemaIndex?true:false;e.animateSchemaChange=e.toNextSchema?"animated fadeOutUp":"animated fadeOutDown";r(function(){f(n.params.schemaIndex)},250)}else f(n.params.schemaIndex);var i=e.$watch("resultHasArrived",function(e,t){if(e){c();i()}})}else c()});var y=e.$watch("resultHasArrived",function(t,n){if(t){if(u.getAnimationStatus()){switch(m.toNextPage){case false:e.animateWorkspacePageChange="animated slideInLeft";break;case true:e.animateWorkspacePageChange="animated slideInRight";break;default:e.animateWorkspacePageChange="animated fadeInDown"}r(function(){e.animateWorkspacePageChange=""},250)}else e.animateWorkspacePageChange="";c();m.workspaceFullyLoaded=true;y()}})}]);SCHEMAcat.controller("NamePanelCtrl",["$scope","$location","$timeout","Schema",function(e,t,n,r){e.workspace.namePanel={};var i;e.workspace.namePanel.updateEditingName=function(){if(t.search().editingName){if(e.schemaEditable){e.workspace.namePanel.editButtonTooltip="Hide edit name";if(i===undefined)i=e.selectedSchema["sc:schema"]["sc:name"];e.workspace.namePanel.editForm.open=true}else{delete t.search().editingName;e.workspace.namePanel.editButtonTooltip="Edit schema name";if(e.workspace.namePanel.editForm.input.$dirty)e.workspace.namePanel.editButtonTooltip+=" (there are unsaved changes in this field!)";t.search(t.search())}}else{e.workspace.namePanel.editForm.open=false;e.workspace.namePanel.editButtonTooltip="Edit schema name";if(e.workspace.namePanel.editForm.input.$dirty)e.workspace.namePanel.editButtonTooltip+=" (there are unsaved changes in this field!)"}e.workspace.namePanel.updateAjaxError=false};e.saveName=function(){var n=e.selectedSchema["sc:schema"]["sc:name"];var s=new r;e.workspace.namePanel.waitingForServerUpdate=true;e.workspace.namePanel.updateAjaxError=false;s.name=n;s.$save({schemaID:e.schemasList[e.selectedSchemaIndex]["xml:id"],schemaField:"name"},function(n){if(n["sc:response"]!==undefined&&n["sc:response"]&&n["sc:response"].success){e.selectedSchema["sc:schema"]["sc:name"]=fixEmptyFields(n["sc:response"]["sc:written-data"]["sc:name"]);i=n["sc:response"]["sc:written-data"]["sc:name"];e.workspace.namePanel.waitingForServerUpdate=false;e.workspace.namePanel.editForm.$setPristine();delete t.search().editingName;t.search(t.search())}else{e.workspace.namePanel.waitingForServerUpdate=false;e.workspace.namePanel.updateAjaxError=true}},function(){e.workspace.namePanel.waitingForServerUpdate=false;e.workspace.namePanel.updateAjaxError=true})};e.toggleEditName=function(r){if(t.search().editingName){delete t.search().editingName;if(r){n(function(){e.selectedSchema["sc:schema"]["sc:name"]=i;e.workspace.namePanel.editForm.$setPristine();e.$apply();t.search(t.search())},150);return}}else{t.search().editingName=true}t.search(t.search())}}]);SCHEMAcat.controller("DescriptionPanelCtrl",["$scope","$location","$timeout","Schema",function(e,t,n,r){e.workspace.descriptionPanel={};var i;e.workspace.descriptionPanel.updateEditingDescription=function(){if(t.search().editingDescription){if(e.schemaEditable){if(e.workspaceFullyLoaded)e.$broadcast("autosizeTextarea.resize");e.workspace.descriptionPanel.editButtonTooltip="Hide edit description";if(i===undefined)i=e.selectedSchema["sc:schema"]["sc:description"];e.workspace.descriptionPanel.editForm.open=true}else{delete t.search().editingDescription;e.workspace.descriptionPanel.editButtonTooltip="Edit description";if(e.workspace.descriptionPanel.editForm.input.$dirty)e.workspace.descriptionPanel.editButtonTooltip+=" (there are unsaved changes in this field!)";t.search(t.search())}}else{e.workspace.descriptionPanel.editForm.open=false;e.workspace.descriptionPanel.editButtonTooltip="Edit description";if(e.workspace.descriptionPanel.editForm.input.$dirty)e.workspace.descriptionPanel.editButtonTooltip+=" (there are unsaved changes in this field!)"}e.workspace.descriptionPanel.updateAjaxError=false};e.saveDescription=function(){var n=e.selectedSchema["sc:schema"]["sc:description"];var s=new r;e.workspace.descriptionPanel.waitingForServerUpdate=true;e.workspace.descriptionPanel.updateAjaxError=false;s.description=n;s.$save({schemaID:e.schemasList[e.selectedSchemaIndex]["xml:id"],schemaField:"description"},function(n){if(n["sc:response"]!==undefined&&n["sc:response"]&&n["sc:response"].success){e.selectedSchema["sc:schema"]["sc:description"]=fixEmptyFields(n["sc:response"]["sc:written-data"]["sc:description"]);i=n["sc:response"]["sc:written-data"]["sc:description"];e.workspace.descriptionPanel.waitingForServerUpdate=false;e.workspace.descriptionPanel.editForm.$setPristine();delete t.search().editingDescription;t.search(t.search())}else{e.workspace.descriptionPanel.waitingForServerUpdate=false;e.workspace.descriptionPanel.updateAjaxError=true}},function(){e.workspace.descriptionPanel.waitingForServerUpdate=false;e.workspace.descriptionPanel.updateAjaxError=true})};e.toggleEditDescription=function(r){if(t.search().editingDescription){delete t.search().editingDescription;if(r){n(function(){e.selectedSchema["sc:schema"]["sc:description"]=i;e.workspace.descriptionPanel.editForm.$setPristine();e.$apply();t.search(t.search())},150);return}}else{t.search().editingDescription=true}t.search(t.search())}}]);SCHEMAcat.controller("VersionDetailsPanelCtrl",["$scope","$location","$timeout","Schema",function(e,t,n,r){e.workspace.collapsibleDetailPanels.version={};e.workspace.collapsibleDetailPanels.version.editPanel={};e.workspace.collapsibleDetailPanels.version.editPanel.open=false;var i;e.toggleEditVersion=function(r){if(t.search().editingVersion){delete t.search().editingVersion;if(r){n(function(){e.workspace.collapsibleDetailPanels.version.editForm.$setPristine();e.$apply();t.search(t.search());e.workspace.collapsibleDetailPanels.version.resettingUpdate=true;n(function(){e.selectedSchema["sc:schema"]["sc:version"]=i;e.workspace.collapsibleDetailPanels.version.resettingUpdate=false},350)},150);return}}else t.search().editingVersion=true;t.search(t.search())};e.workspace.collapsibleDetailPanels.version.updateEditPanel=function(){if(t.search().editingVersion){if(e.schemaEditable){e.workspace.collapsibleDetailPanels.version.editButtonTooltip="Hide edit panel";if(i===undefined)i=e.selectedSchema["sc:schema"]["sc:version"];e.workspace.collapsibleDetailPanels.version.editPanel.open=true}else{delete t.search().editingVersion;e.workspace.collapsibleDetailPanels.version.editButtonTooltip="Change schema version";if(e.workspace.collapsibleDetailPanels.version.editForm&&e.workspace.collapsibleDetailPanels.version.editForm.input.$dirty)e.workspace.collapsibleDetailPanels.version.editButtonTooltip+=" (there are unsaved changes in this field!)";t.search(t.search())}}else{e.workspace.collapsibleDetailPanels.version.editPanel.open=false;e.workspace.collapsibleDetailPanels.version.editButtonTooltip="Change schema version";if(e.workspace.collapsibleDetailPanels.version.editForm&&e.workspace.collapsibleDetailPanels.version.editForm.input.$dirty)e.workspace.collapsibleDetailPanels.version.editButtonTooltip+=" (there are unsaved changes in this field!)"}e.workspace.collapsibleDetailPanels.version.updateAjaxError=false};e.saveVersion=function(){var n=e.selectedSchema["sc:schema"]["sc:version"];var s=new r;e.workspace.collapsibleDetailPanels.version.waitingForServerUpdate=true;e.workspace.collapsibleDetailPanels.version.updateAjaxError=false;s.version=n;s.$save({schemaID:e.selectedSchema["sc:schema"]["xml:id"],schemaField:"version"},function(n){if(n["sc:response"]!==undefined&&n["sc:response"]&&n["sc:response"].success){e.selectedSchema["sc:schema"]["sc:version"]=fixEmptyFields(n["sc:response"]["sc:written-data"]["sc:version"]);i=e.selectedSchema["sc:schema"]["sc:version"];e.schemasList[e.selectedSchemaIndex]["sc:version"]=i;e.workspace.collapsibleDetailPanels.version.waitingForServerUpdate=false;e.workspace.collapsibleDetailPanels.version.editForm.$setPristine();delete t.search().editingVersion;t.search(t.search())}else{e.workspace.collapsibleDetailPanels.version.waitingForServerUpdate=false;e.workspace.collapsibleDetailPanels.version.updateAjaxError=true}},function(){e.workspace.collapsibleDetailPanels.version.waitingForServerUpdate=false;e.workspace.collapsibleDetailPanels.version.updateAjaxError=true})}}]);SCHEMAcat.controller("StatusDetailsPanelCtrl",["$scope","$location","Schema",function(e,t,n){e.workspace.collapsibleDetailPanels.status={};e.workspace.collapsibleDetailPanels.status.editPanel={};e.workspace.collapsibleDetailPanels.status.editPanel.open=false;e.workspace.collapsibleDetailPanels.status.possibleStatusList=[];var r=["development"];var i=["production"];var s=["deprecated","superseeded"];e.toggleEditStatus=function(){if(t.search().editingStatus)delete t.search().editingStatus;else t.search().editingStatus=true;t.search(t.search())};e.workspace.collapsibleDetailPanels.status.updateEditPanel=function(){if(t.search().editingStatus){if(e.schemaEditable){if(e.selectedSchema["sc:schema"]["sc:access"]["sc:all"]&&e.selectedSchema["sc:schema"]["sc:access"]["sc:all"].actions==="r")e.workspace.collapsibleDetailPanels.status.possibleStatusList=i.concat(s);else e.workspace.collapsibleDetailPanels.status.possibleStatusList=r.concat(s);e.workspace.collapsibleDetailPanels.status.editPanel.open=true}else{delete t.search().editingStatus;t.search(t.search())}}else e.workspace.collapsibleDetailPanels.status.editPanel.open=false;e.workspace.collapsibleDetailPanels.status.updateAjaxError=false};e.saveStatus=function(){var t=e.selectedSchema["sc:schema"]["sc:status"];var r=new n;e.workspace.collapsibleDetailPanels.status.waitingForServerUpdate=true;e.workspace.collapsibleDetailPanels.status.updateAjaxError=false;r.status=t;r.$save({schemaID:e.selectedSchema["sc:schema"]["xml:id"],schemaField:"status"},function(t){if(t["sc:response"]!==undefined&&t["sc:response"]&&t["sc:response"].success){e.selectedSchema["sc:schema"]["sc:status"]=fixEmptyFields(t["sc:response"]["sc:written-data"]["sc:status"]);e.schemasList[e.selectedSchemaIndex]["sc:status"]=e.selectedSchema["sc:schema"]["sc:status"];e.workspace.collapsibleDetailPanels.status.editForm.$setPristine();e.workspace.collapsibleDetailPanels.status.waitingForServerUpdate=false}else{e.workspace.collapsibleDetailPanels.status.waitingForServerUpdate=false;e.workspace.collapsibleDetailPanels.status.updateAjaxError=true}},function(){e.workspace.collapsibleDetailPanels.status.waitingForServerUpdate=false;e.workspace.collapsibleDetailPanels.status.updateAjaxError=true})}}]);SCHEMAcat.controller("AccessDetailsPanelCtrl",["$scope","$location","Schema",function(e,t,n){e.workspace.collapsibleDetailPanels.access={};e.workspace.collapsibleDetailPanels.access.editPanel={};e.workspace.collapsibleDetailPanels.access.editPanel.open=false;e.currentAccessPolicy="";e.toggleEditAccess=function(){if(t.search().editingAccess)delete t.search().editingAccess;else t.search().editingAccess=true;t.search(t.search())};e.workspace.collapsibleDetailPanels.access.updateEditPanel=function(){if(t.search().editingAccess){if(e.schemaEditable){e.currentAccessPolicy=e.workspace.collapsibleDetailPanels.access.getAccessPolicy();e.workspace.collapsibleDetailPanels.access.editPanel.open=true}else{delete t.search().editingAccess;t.search(t.search())}}else e.workspace.collapsibleDetailPanels.access.editPanel.open=false;e.workspace.collapsibleDetailPanels.access.updateAjaxError=false};e.workspace.collapsibleDetailPanels.access.getAccessPolicy=function(){if(e.selectedSchema["sc:schema"]["sc:access"]["sc:all"]!==undefined&&e.selectedSchema["sc:schema"]["sc:access"]["sc:all"].actions==="r")return"shareURL";else return"private"};e.saveAccessStatus=function(t){var r=e.selectedSchema["sc:schema"]["sc:access"]["sc:user"];var i=new n;e.workspace.collapsibleDetailPanels.access.waitingForServerUpdate=true;e.workspace.collapsibleDetailPanels.access.updateAjaxError=false;switch(t){case"shareURL":i.access={all:{actions:"r"},user:r};break;case"private":i.access={user:r};break}i.$save({schemaID:e.selectedSchema["sc:schema"]["xml:id"],schemaField:"access"},function(t){if(t["sc:response"]!==undefined&&t["sc:response"]&&t["sc:response"].success){e.selectedSchema["sc:schema"]["sc:access"]=t["sc:response"]["sc:written-data"]["sc:access"];e.workspace.collapsibleDetailPanels.access.editForm.$setPristine();e.workspace.collapsibleDetailPanels.access.waitingForServerUpdate=false}else{e.workspace.collapsibleDetailPanels.access.waitingForServerUpdate=false;e.workspace.collapsibleDetailPanels.access.updateAjaxError=true}e.currentAccessPolicy=e.workspace.collapsibleDetailPanels.access.getAccessPolicy()},function(){e.workspace.collapsibleDetailPanels.access.waitingForServerUpdate=false;e.workspace.collapsibleDetailPanels.access.updateAjaxError=true;e.currentAccessPolicy=e.workspace.collapsibleDetailPanels.access.getAccessPolicy()})}}]);SCHEMAcat.controller("LicenseDetailsPanelCtrl",["$scope","$modal","$location","$timeout","Schema","Licenses",function(e,t,n,r,i,s){function a(){u=t.open({scope:e,templateUrl:"partials/editLicenseModal.html"});u.result.then(function(){u=undefined},function(t){u=undefined;if(t!=="dismiss")e.triggerCloseModalRoute()})}e.workspace.collapsibleDetailPanels.license={};e.input={};var o;var u;e.filterLicenses=function(t){var n=new RegExp(e.workspace.collapsibleDetailPanels.license.editForm.filterTerm.$modelValue,"i");if(t["sc:full-name"].match(n)||t["xml:id"].match(n)||e.workspace.collapsibleDetailPanels.license.editForm.filterTerm.$modelValue===undefined){return true}return false};e.showSelectedLicense=function(t){if(e.selectedSchema["sc:schema"]["sc:license"]["xml:id"]!==t["xml:id"]){e.workspace.collapsibleDetailPanels.license.modelDirty=true;e.workspace.collapsibleDetailPanels.license.updatingLicense=true;r(function(){e.selectedSchema["sc:schema"]["sc:license"]=t;e.workspace.collapsibleDetailPanels.license.updatingLicense=false},250)}};e.saveNewLicense=function(){var t=e.selectedSchema["sc:schema"]["sc:license"];var n=new i;e.workspace.collapsibleDetailPanels.license.waitingForServerUpdate=true;e.workspace.collapsibleDetailPanels.license.updateAjaxError=false;n.license=t["xml:id"];n.$save({schemaID:e.selectedSchema["sc:schema"]["xml:id"],schemaField:"license"},function(t){if(t["sc:response"]!==undefined&&t["sc:response"]&&t["sc:response"].success&&t["sc:response"]["sc:written-data"]["sc:license"].ref===e.selectedSchema["sc:schema"]["sc:license"]["xml:id"]){o=e.selectedSchema["sc:schema"]["sc:license"];e.workspace.collapsibleDetailPanels.license.modelDirty=false;e.workspace.collapsibleDetailPanels.license.editForm.$setPristine();e.workspace.collapsibleDetailPanels.license.waitingForServerUpdate=false;e.triggerCloseModalRoute()}else{e.workspace.collapsibleDetailPanels.license.waitingForServerUpdate=false;e.workspace.collapsibleDetailPanels.license.updateAjaxError=true}},function(){e.selectedSchema["sc:schema"]["sc:license"]=o;e.workspace.collapsibleDetailPanels.license.waitingForServerUpdate=false;e.workspace.collapsibleDetailPanels.license.updateAjaxError=true})};e.triggerOpenModalRoute=function(){if(!n.search().editingLicense){n.search().editingLicense=true;n.search(n.search())}};e.triggerCloseModalRoute=function(){if(n.search().editingLicense){delete n.search().editingLicense;n.search(n.search())}};e.workspace.collapsibleDetailPanels.license.updateEditPanel=function(){if(n.search().editingLicense){if(e.schemaEditable){if(o===undefined)o=e.selectedSchema["sc:schema"]["sc:license"];if(e.workspace.collapsibleDetailPanels.license.licenseList===undefined){e.workspace.collapsibleDetailPanels.license.licensesArrived=false;s.get(function(t){e.workspace.collapsibleDetailPanels.license.licenseList=t;for(var n=0;n<t["sc:licenses"]["sc:license"].length;n++){if(t["sc:licenses"]["sc:license"][n]["xml:id"]===e.selectedSchema["sc:schema"]["sc:license"]["xml:id"])e.input.model=e.workspace.collapsibleDetailPanels.license.licenseList["sc:licenses"]["sc:license"][n]["xml:id"]}e.workspace.collapsibleDetailPanels.license.licensesArrived=true})}a()}else{e.workspace.collapsibleDetailPanels.license.editButtonTooltip="Change schema license";if(e.workspace.collapsibleDetailPanels.license.editForm&&e.workspace.collapsibleDetailPanels.license.modelDirty)e.workspace.collapsibleDetailPanels.license.editButtonTooltip+=" (there are unsaved changes in this field!)";e.triggerCloseModalRoute()}}else if(u!==undefined){u.dismiss("dismiss")}e.workspace.collapsibleDetailPanels.license.editButtonTooltip="Change schema license";if(e.workspace.collapsibleDetailPanels.license.editForm&&e.workspace.collapsibleDetailPanels.license.modelDirty)e.workspace.collapsibleDetailPanels.license.editButtonTooltip+=" (there are unsaved changes in this field!)"};e.cancelEdit=function(){if(e.workspace.collapsibleDetailPanels.license.modelDirty){e.workspace.collapsibleDetailPanels.license.updatingLicense=true;e.workspace.collapsibleDetailPanels.license.modelDirty=false;r(function(){e.selectedSchema["sc:schema"]["sc:license"]=o;e.workspace.collapsibleDetailPanels.license.updatingLicense=false},250);e.workspace.collapsibleDetailPanels.license.editForm.$setPristine()}e.triggerCloseModalRoute()}}]);SCHEMAcat.controller("FileController",["$scope","$http","$timeout","$location",function(e,t,n,r){function i(){if(r.search().show!==undefined&&r.search().show.indexOf(e.file["sc:name"])!==-1){e.showSchemaBtn=true;s(e.selectedSchema["sc:schema"]["xml:id"],e.file["sc:name"])}else{e.showSchemaBtn=false;e.file.open=false}}function s(r,i){if(e.schemaFileContent===undefined){t.get("/schemacat/schemas/"+r+"/files/"+i).success(function(t,r,i,s){e.prettify="prettyprint linenums";n(function(){prettyPrint();e.file.open=true});e.schemaFileContent=t}).error(function(t,n,r,s){e.showSchemaBtn=false;e.showFile(i);e.showFileAjaxError=true})}else e.file.open=true}i();e.showFile=function(t){e.showFileAjaxError=false;n(function(){var n=r.search();if(e.showSchemaBtn===true){if(n.show===undefined)n.show="#"+t;else if(n.show.indexOf(t)===-1)n.show=n.show+"#"+t}else{for(var i in n){if(i==="show"){var s=n[i].split("#");for(var o in s){if(s[o]===t)s.splice(o,1)}var u=s.join("#");if(u!==""){n[i]=u}else delete n[i]}}}r.search(n)})};e.$on("$routeUpdate",function(t,n){if(e.resultHasArrived)i()})}]);SCHEMAcat.controller("TopMenuCtrl",["$scope","$modal","$location","UserService","Settings","ShibService",function(e,t,n,r,i,s){function o(){e.topMenuCollapsed=!n.search().topMenuExpanded;i.setAnimationStatus(!n.search().animationsDisabled);e.animationsChecked=i.getAnimationStatus()}e.displayName=r.displayName;e.shibURL=s.url;e.$watch(function(){return r.displayName},function(t,n){if(t!==n){e.displayName=t}});o();e.isActive=function(e){if(e==="/workspace.html"&&n.path().indexOf("/workspace.html/")!==-1)return true;return e===n.path()};e.updateAnimationStatus=function(){if(n.search().animationsDisabled)delete n.search().animationsDisabled;else n.search().animationsDisabled=true;n.search(n.search())};e.toggleTopMenu=function(){if(n.search().topMenuExpanded)delete n.search().topMenuExpanded;else n.search().topMenuExpanded=true;n.search(n.search())};e.animationsUrlPart=function(){if(n.search().animationsDisabled)return"animationsDisabled";else return""};e.topMenuExpandedUrlPart=function(){if(n.search().topMenuExpanded)return"topMenuExpanded";else return""};e.$on("$routeUpdate",function(e,t){o()});e.loginClick=function(){var n=t.open({scope:e,templateUrl:"partials/loginModal.html",controller:"LoginModalCtrl"});n.result.then(function(e){alert("Now set the user cookie to ["+e+"]");document.cookie="USER="+e+";domain=;path=/";document.location.hash="";document.location.reload(true)})}}]);SCHEMAcat.controller("LoginModalCtrl",["$scope","$modalInstance",function(e,t){e.loginClose=function(){t.dismiss("cancel")};e.loginSubmit=function(){t.close(this.loginNameInput.text)}}]);SCHEMAcat.controller("AboutPageCtrl",["$scope","Settings",function(e,t){e.$parent.toNextPage=false;if(t.getAnimationStatus()){e.animateInOut="animated slideInRight"}e.$on("$routeChangeStart",function(n,r,i){if(t.getAnimationStatus()){switch(r.templateUrl){case"partials/workspace.html":e.animateInOut="animated slideOutRight";break;case"partials/contact.html":e.animateInOut="animated slideOutLeft";break;default:e.animateInOut="animated fadeOutDown"}}});e.$on("$routeChangeSuccess",function(n,r,i){if(t.getAnimationStatus()){var s=i!==undefined?i.templateUrl:undefined;switch(s){case"partials/workspace.html":e.animateInOut="animated slideInRight";break;case"partials/contact.html":e.animateInOut="animated slideInLeft";break;default:e.animateInOut="animated fadeInDown"}}})}]);SCHEMAcat.controller("ContactPageCtrl",["$scope","Settings",function(e,t){e.$parent.toNextPage=false;if(t.getAnimationStatus()){e.animateInOut="animated slideInRight"}e.$on("$routeChangeStart",function(n,r,i){if(t.getAnimationStatus()){switch(r.templateUrl){case"partials/about.html":case"partials/contact.html":case"partials/workspace.html":e.animateInOut="animated slideOutRight";break;default:e.animateInOut="animated fadeOutDown"}}});e.$on("$routeChangeSuccess",function(n,r,i){if(t.getAnimationStatus()){var s=i!==undefined?i.templateUrl:undefined;switch(s){case"partials/about.html":case"partials/contact.html":case"partials/workspace.html":e.animateInOut="animated slideInRight";break;default:e.animateInOut="animated fadeInDown"}}})}]);SCHEMAcat.controller("AccountDetailsPageCtrl",["$scope","$location","User","UserService","Settings",function(e,t,n,r,i){function s(){var e=t.search();for(var n in e){if(n==="editingEmail"){var i=e[n].split("#");for(var s=0;s<i.length;s++){var o=false;for(var u=0;u<r.email.length;u++){if(i[s]===r.email[u])o=true}if(!o)i.splice(s,1)}var a=i.join("#");if(a!==""){e[n]=a}else delete e[n]}}t.search(e)}function o(){e.waitingForServerEditDisplayName=false;e.editDisplayNameAjaxError=false;if(t.search().editingDisplayName){e.editDisplayNameText=e.displayName;e.editingDisplayName=true}else e.editingDisplayName=false}function u(){e.waitingForServer=false;if(t.search().addingEmail)e.addingEmail=true;else e.addingEmail=false}e.principal=r.principal;e.displayName=r.displayName;e.email=r.email;e.addingEmail=false;e.addNewEmail=function(){t.search().addingEmail=true;t.search(t.search())};e.terminateAddEmail=function(){e.ajaxError=false;delete t.search().addingEmail;t.search(t.search())};e.addEmail=function(t){e.waitingForServer=true;var i=new n;i.emails=r.email.slice(0);i.emails.push(t);i.$save({userID:r.id},function(n){if(n["sc:response"]!==undefined&&n["sc:response"]&&n["sc:response"].success){r.email.push(t);e.terminateAddEmail()}else{e.waitingForServer=false;e.ajaxError=true}},function(){e.waitingForServer=false;e.ajaxError=true})};e.editDisplayName=function(){t.search().editingDisplayName=true;t.search(t.search())};e.terminateEditDisplayName=function(){delete t.search().editingDisplayName;t.search(t.search())};e.updateDisplayName=function(t){e.waitingForServerEditDisplayName=true;var i=new n;i.displayName=t;i.$save({userID:r.id},function(n){if(n["sc:response"]!==undefined&&n["sc:response"]&&n["sc:response"].success){e.displayName=r.displayName=t;e.terminateEditDisplayName()}else{e.waitingForServerEditDisplayName=false;e.editDisplayNameAjaxError=true}},function(){e.waitingForServerEditDisplayName=false;e.editDisplayNameAjaxError=true})};if(i.getAnimationStatus()){e.animateAccountDetails="animated fadeInDown"}e.$on("$routeChangeStart",function(t,n,r){if(i.getAnimationStatus()){e.animateAccountDetails="animated fadeOutUp"}});e.$on("$routeChangeSuccess",function(t,n,r){if(i.getAnimationStatus()){e.animateAccountDetails="animated fadeInDown"}u();o();s()});e.$on("$routeUpdate",function(e,t){u();o();s()})}]);SCHEMAcat.controller("EmailInstanceCtrl",["$scope","$location","User","UserService",function(e,t,n,r){function i(){e.waitingForServerEditEmail=false;if(t.search().editingEmail!==undefined&&t.search().editingEmail.indexOf(e.emailInstance)!==-1){e.editEmailText=e.emailInstance;e.editingEmail=true}else e.editingEmail=false}i();e.editEmail=function(n){var r=t.search();e.removeEmailAjaxError=false;if(r.editingEmail===undefined)r.editingEmail=n;else r.editingEmail=t.search().editingEmail+"#"+n;t.search(r)};e.removeEmail=function(t){e.waitingForServerEditEmail=true;var i=new n;i.emails=r.email.slice(0);i.emails.splice(t,1);i.$save({userID:r.id},function(n){if(n["sc:response"]!==undefined&&n["sc:response"]&&n["sc:response"].success){r.email.splice(t,1)}else{e.waitingForServerEditEmail=false;e.removeEmailAjaxError=true}},function(){e.waitingForServerEditEmail=false;e.removeEmailAjaxError=true})};e.updateEmail=function(t){e.waitingForServerEditEmail=true;var i=new n;i.emails=r.email.slice(0);i.emails[t]=e.editEmailText;i.$save({userID:r.id},function(n){if(n["sc:response"]!==undefined&&n["sc:response"]&&n["sc:response"].success){var i=e.editEmailText;e.cancelEditEmail(r.email[t]);r.email[t]=i}else{e.waitingForServerEditEmail=false;e.editEmailAjaxError=true}},function(){e.waitingForServerEditEmail=false;e.editEmailAjaxError=true})};e.cancelEditEmail=function(n){var r=t.search();e.editEmailAjaxError=false;for(var i in r){if(i==="editingEmail"){var s=r[i].split("#");for(var o in s){if(s[o]===n)s.splice(o,1)}var u=s.join("#");if(u!==""){r[i]=u}else delete r[i]}}t.search(r)};e.$on("$routeChangeSuccess",function(e,t,n){i()});e.$on("$routeUpdate",function(e,t){i()})}]);SCHEMAcat.controller("CompleteUserDetailsCtrl",["$scope","$modal",function(e,t){e.ajaxError=false;e.waitingForServer=false;var n=t.open({scope:e,backdrop:"static",keyboard:false,templateUrl:"partials/fillDetailsModal.html",controller:"CompleteUserDetailsModalCtrl"})}]);SCHEMAcat.controller("CompleteUserDetailsModalCtrl",["$scope","$modalInstance","User","UserService",function(e,t,n,r){e.userDetailsSubmit=function(){e.waitingForServer=true;e.ajaxError=false;var t=new n;t.emails=[];t.emails[0]=this.emailInput.text;t.displayName=this.displayNameInput.text;t.$save({userID:r.id},function(t){if(t["sc:response"]!==undefined&&t["sc:response"]&&t["sc:response"].success)document.location.pathname="schemacat/site/index.html";else{e.waitingForServer=false;e.ajaxError=true}},function(){e.waitingForServer=false;e.ajaxError=true})}}])
+"use strict";function prepareArrayForNgRepeat(a){var b;return b=a instanceof Array?a:new Array(a)}function isEmptyObj(a){if(a instanceof Object){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0}return!1}function fixEmptyFields(a){if(isEmptyObj(a))return"";for(var b in a)a.hasOwnProperty(b)&&(isEmptyObj(a[b])?a[b]="":a[b]instanceof Object&&fixEmptyFields(a[b]));return a}SCHEMAcat.controller("WorkspaceCtrl",["$scope","$location","$routeParams","$timeout","SchemasList","Schema","UserService","Settings",function(a,b,c,d,e,f,g,h){function i(c){return isNaN(parseInt(c,10))||1>c?(b.path("workspace/page/1/").search({schemaIndex:0}),void 0):(e.get({userID:g.id,startPage:c,pageSize:a.pageSize},function(d){return c>Math.ceil(d["sc:result"]["sc:total-schemas"]/a.pageSize)?(b.path("workspace/page/1/").search({schemaIndex:0}),void 0):(q.totalSchemaItems=d["sc:result"]["sc:total-schemas"],q.currentPage=Number(c),q.schemasList=prepareArrayForNgRepeat(d["sc:result"]["sc:schemas"]["sc:schema"]),j(b.search().schemaIndex),q.schemasResult=fixEmptyFields(d),void 0)}),void 0)}function j(c){if("invisible"!==a.animateWorkspacePageChange&&(a.animateSchemaChange="invisible"),isNaN(parseInt(c,10))||0>c||c>a.schemasList.length-1)return a.selectedSchemaIndex=void 0,b.search({schemaIndex:0}),void 0;a.selectedSchemaIndex=c;var d=q.schemasList[Number(c)];f.get({schemaID:d["xml:id"]},function(b){if(q.filesList=prepareArrayForNgRepeat(b["sc:schema"]["sc:files"]["sc:file"]),q.selectedSchema=fixEmptyFields(b),q.schemaEditable=g.id===k()||-1!==g.roles.indexOf("admin"),q.resultHasArrived=!0,h.getAnimationStatus())switch(a.toNextSchema){case!0:a.animateSchemaChange="animated fadeInUp";break;case!1:a.animateSchemaChange="animated fadeInDown";break;case void 0:a.animateSchemaChange="animated fadeInDown"}else a.animateSchemaChange=""})}function k(){var a,b=prepareArrayForNgRepeat(q.selectedSchema["sc:schema"]["sc:access"]["sc:user"]);for(var c in b)"owner"===b[c].role&&(a=b[c].ref);return a}function l(){a.workspace.namePanel.updateEditingName(),a.workspace.descriptionPanel.updateEditingDescription(),m()}function m(){var a=!1;for(var c in r)b.search().hasOwnProperty(r[c])&&(p(c),a=!0);a||n("")}function n(b){for(var c in a.workspace.collapsibleDetailPanels)if(c!==b&&(a.workspace.collapsibleDetailPanels[c].detailButtonTooltip="Show field details",a.workspace.collapsibleDetailPanels[c].open===!0))return o(c),!0;return!1}function o(b){(a.workspace.collapsibleDetailPanels[b].editForm&&a.workspace.collapsibleDetailPanels[b].editForm.$dirty||a.workspace.collapsibleDetailPanels[b].modelDirty)&&(a.workspace.collapsibleDetailPanels[b].detailButtonTooltip+=" (there are unsaved changes in this field!)"),a.workspace.collapsibleDetailPanels[b].open=!1}function p(b){function c(b){void 0!==a.workspace.collapsibleDetailPanels[b]&&void 0!==a.workspace.collapsibleDetailPanels[b].updateEditPanel&&a.workspace.collapsibleDetailPanels[b].updateEditPanel(),a.workspace.collapsibleDetailPanels[b].detailButtonTooltip="Hide field details",a.workspace.collapsibleDetailPanels[b].open=!0}r.hasOwnProperty(b)&&(n(b)?d(function(){c(b)},350):c(b))}var q=a.$parent;q.pageSize=10;var r={version:"showVersionDetails",status:"showStatusDetails",access:"showAccessDetails",license:"showLicenseDetails"};a.selectedSchemaIndex=c.schemaIndex,a.animateWorkspacePageChange="invisible",a.workspace={},a.location=location,q.workspaceFullyLoaded||i(c.pageNumber),a.selectPage=function(a){b.search().schemaIndex="0",delete b.search().show,b.path("workspace.html/page/"+a+"/").search(b.search())},a.selectSchema=function(a){b.search().schemaIndex=a.toString(),delete b.search().show,b.search(b.search())},a.toggleDetailsPanel=function(a){var c=r[a];if(b.search()[c])delete b.search()[c];else{for(var d in r)r[d]!==c&&delete b.search()[r[d]];b.search()[r[a]]=!0}b.search(b.search())},a.$on("$routeChangeStart",function(b,c,d){if(q.resultHasArrived=!1,h.getAnimationStatus())switch(q.toNextPage=void 0!==c.params&&void 0!==c.params.pageNumber&&c.params.pageNumber>d.params.pageNumber?!0:!1,c.templateUrl){case"partials/workspace.html":a.animateWorkspacePageChange=q.toNextPage?"animated slideOutLeft":"animated slideOutRight";break;case"partials/contact.html":case"partials/about.html":a.animateWorkspacePageChange="animated slideOutLeft";break;default:a.animateWorkspacePageChange="animated fadeOutDown"}"partials/workspace.html"===c.templateUrl?i(c.params.pageNumber):q.workspaceFullyLoaded=!1}),a.$on("$routeChangeSuccess",function(a,b,c){h.getAnimationStatus()&&(void 0===c||void 0===c.templateUrl||"partials/accountDetails.html"===c.templateUrl)&&(q.toNextPage=void 0)}),a.$on("$routeUpdate",function(b,c){if("partials/workspace.html"===c.templateUrl&&c.params.schemaIndex!==a.selectedSchemaIndex){q.resultHasArrived=!1,h.getAnimationStatus()?(a.toNextSchema=c.params.schemaIndex>a.selectedSchemaIndex?!0:!1,a.animateSchemaChange=a.toNextSchema?"animated fadeOutUp":"animated fadeOutDown",d(function(){j(c.params.schemaIndex)},250)):j(c.params.schemaIndex);var e=a.$watch("resultHasArrived",function(a){a&&(l(),e())})}else l()});var s=a.$watch("resultHasArrived",function(b){if(b){if(h.getAnimationStatus()){switch(q.toNextPage){case!1:a.animateWorkspacePageChange="animated slideInLeft";break;case!0:a.animateWorkspacePageChange="animated slideInRight";break;default:a.animateWorkspacePageChange="animated fadeInDown"}d(function(){a.animateWorkspacePageChange=""},250)}else a.animateWorkspacePageChange="";l(),q.workspaceFullyLoaded=!0,s()}})}]),SCHEMAcat.controller("NamePanelCtrl",["$scope","$location","$timeout","Schema",function(a,b,c,d){a.workspace.namePanel={};var e;a.workspace.namePanel.updateEditingName=function(){b.search().editingName?a.schemaEditable?(a.workspace.namePanel.editButtonTooltip="Hide edit name",void 0===e&&(e=a.selectedSchema["sc:schema"]["sc:name"]),a.workspace.namePanel.editForm.open=!0):(delete b.search().editingName,a.workspace.namePanel.editButtonTooltip="Edit schema name",a.workspace.namePanel.editForm.input.$dirty&&(a.workspace.namePanel.editButtonTooltip+=" (there are unsaved changes in this field!)"),b.search(b.search())):(a.workspace.namePanel.editForm.open=!1,a.workspace.namePanel.editButtonTooltip="Edit schema name",a.workspace.namePanel.editForm.input.$dirty&&(a.workspace.namePanel.editButtonTooltip+=" (there are unsaved changes in this field!)")),a.workspace.namePanel.updateAjaxError=!1},a.saveName=function(){var c=a.selectedSchema["sc:schema"]["sc:name"],f=new d;a.workspace.namePanel.waitingForServerUpdate=!0,a.workspace.namePanel.updateAjaxError=!1,f.name=c,f.$save({schemaID:a.schemasList[a.selectedSchemaIndex]["xml:id"],schemaField:"name"},function(c){void 0!==c["sc:response"]&&c["sc:response"]&&c["sc:response"].success?(a.selectedSchema["sc:schema"]["sc:name"]=fixEmptyFields(c["sc:response"]["sc:written-data"]["sc:name"]),e=c["sc:response"]["sc:written-data"]["sc:name"],a.workspace.namePanel.waitingForServerUpdate=!1,a.workspace.namePanel.editForm.$setPristine(),delete b.search().editingName,b.search(b.search())):(a.workspace.namePanel.waitingForServerUpdate=!1,a.workspace.namePanel.updateAjaxError=!0)},function(){a.workspace.namePanel.waitingForServerUpdate=!1,a.workspace.namePanel.updateAjaxError=!0})},a.toggleEditName=function(d){if(b.search().editingName){if(delete b.search().editingName,d)return c(function(){a.selectedSchema["sc:schema"]["sc:name"]=e,a.workspace.namePanel.editForm.$setPristine(),a.$apply(),b.search(b.search())},150),void 0}else b.search().editingName=!0;b.search(b.search())}}]),SCHEMAcat.controller("DescriptionPanelCtrl",["$scope","$location","$timeout","Schema",function(a,b,c,d){a.workspace.descriptionPanel={};var e;a.workspace.descriptionPanel.updateEditingDescription=function(){b.search().editingDescription?a.schemaEditable?(a.workspaceFullyLoaded&&a.$broadcast("autosizeTextarea.resize"),a.workspace.descriptionPanel.editButtonTooltip="Hide edit description",void 0===e&&(e=a.selectedSchema["sc:schema"]["sc:description"]),a.workspace.descriptionPanel.editForm.open=!0):(delete b.search().editingDescription,a.workspace.descriptionPanel.editButtonTooltip="Edit description",a.workspace.descriptionPanel.editForm.input.$dirty&&(a.workspace.descriptionPanel.editButtonTooltip+=" (there are unsaved changes in this field!)"),b.search(b.search())):(a.workspace.descriptionPanel.editForm.open=!1,a.workspace.descriptionPanel.editButtonTooltip="Edit description",a.workspace.descriptionPanel.editForm.input.$dirty&&(a.workspace.descriptionPanel.editButtonTooltip+=" (there are unsaved changes in this field!)")),a.workspace.descriptionPanel.updateAjaxError=!1},a.saveDescription=function(){var c=a.selectedSchema["sc:schema"]["sc:description"],f=new d;a.workspace.descriptionPanel.waitingForServerUpdate=!0,a.workspace.descriptionPanel.updateAjaxError=!1,f.description=c,f.$save({schemaID:a.schemasList[a.selectedSchemaIndex]["xml:id"],schemaField:"description"},function(c){void 0!==c["sc:response"]&&c["sc:response"]&&c["sc:response"].success?(a.selectedSchema["sc:schema"]["sc:description"]=fixEmptyFields(c["sc:response"]["sc:written-data"]["sc:description"]),e=c["sc:response"]["sc:written-data"]["sc:description"],a.workspace.descriptionPanel.waitingForServerUpdate=!1,a.workspace.descriptionPanel.editForm.$setPristine(),delete b.search().editingDescription,b.search(b.search())):(a.workspace.descriptionPanel.waitingForServerUpdate=!1,a.workspace.descriptionPanel.updateAjaxError=!0)},function(){a.workspace.descriptionPanel.waitingForServerUpdate=!1,a.workspace.descriptionPanel.updateAjaxError=!0})},a.toggleEditDescription=function(d){if(b.search().editingDescription){if(delete b.search().editingDescription,d)return c(function(){a.selectedSchema["sc:schema"]["sc:description"]=e,a.workspace.descriptionPanel.editForm.$setPristine(),a.$apply(),b.search(b.search())},150),void 0}else b.search().editingDescription=!0;b.search(b.search())}}]),SCHEMAcat.controller("VersionDetailsPanelCtrl",["$scope","$location","$timeout","Schema",function(a,b,c,d){a.workspace.collapsibleDetailPanels.version={},a.workspace.collapsibleDetailPanels.version.editPanel={},a.workspace.collapsibleDetailPanels.version.editPanel.open=!1;var e;a.toggleEditVersion=function(d){if(b.search().editingVersion){if(delete b.search().editingVersion,d)return c(function(){a.workspace.collapsibleDetailPanels.version.editForm.$setPristine(),a.$apply(),b.search(b.search()),a.workspace.collapsibleDetailPanels.version.resettingUpdate=!0,c(function(){a.selectedSchema["sc:schema"]["sc:version"]=e,a.workspace.collapsibleDetailPanels.version.resettingUpdate=!1},350)},150),void 0}else b.search().editingVersion=!0;b.search(b.search())},a.workspace.collapsibleDetailPanels.version.updateEditPanel=function(){b.search().editingVersion?a.schemaEditable?(a.workspace.collapsibleDetailPanels.version.editButtonTooltip="Hide edit panel",void 0===e&&(e=a.selectedSchema["sc:schema"]["sc:version"]),a.workspace.collapsibleDetailPanels.version.editPanel.open=!0):(delete b.search().editingVersion,a.workspace.collapsibleDetailPanels.version.editButtonTooltip="Change schema version",a.workspace.collapsibleDetailPanels.version.editForm&&a.workspace.collapsibleDetailPanels.version.editForm.input.$dirty&&(a.workspace.collapsibleDetailPanels.version.editButtonTooltip+=" (there are unsaved changes in this field!)"),b.search(b.search())):(a.workspace.collapsibleDetailPanels.version.editPanel.open=!1,a.workspace.collapsibleDetailPanels.version.editButtonTooltip="Change schema version",a.workspace.collapsibleDetailPanels.version.editForm&&a.workspace.collapsibleDetailPanels.version.editForm.input.$dirty&&(a.workspace.collapsibleDetailPanels.version.editButtonTooltip+=" (there are unsaved changes in this field!)")),a.workspace.collapsibleDetailPanels.version.updateAjaxError=!1},a.saveVersion=function(){var c=a.selectedSchema["sc:schema"]["sc:version"],f=new d;a.workspace.collapsibleDetailPanels.version.waitingForServerUpdate=!0,a.workspace.collapsibleDetailPanels.version.updateAjaxError=!1,f.version=c,f.$save({schemaID:a.selectedSchema["sc:schema"]["xml:id"],schemaField:"version"},function(c){void 0!==c["sc:response"]&&c["sc:response"]&&c["sc:response"].success?(a.selectedSchema["sc:schema"]["sc:version"]=fixEmptyFields(c["sc:response"]["sc:written-data"]["sc:version"]),e=a.selectedSchema["sc:schema"]["sc:version"],a.schemasList[a.selectedSchemaIndex]["sc:version"]=e,a.workspace.collapsibleDetailPanels.version.waitingForServerUpdate=!1,a.workspace.collapsibleDetailPanels.version.editForm.$setPristine(),delete b.search().editingVersion,b.search(b.search())):(a.workspace.collapsibleDetailPanels.version.waitingForServerUpdate=!1,a.workspace.collapsibleDetailPanels.version.updateAjaxError=!0)},function(){a.workspace.collapsibleDetailPanels.version.waitingForServerUpdate=!1,a.workspace.collapsibleDetailPanels.version.updateAjaxError=!0})}}]),SCHEMAcat.controller("StatusDetailsPanelCtrl",["$scope","$location","Schema",function(a,b,c){a.workspace.collapsibleDetailPanels.status={},a.workspace.collapsibleDetailPanels.status.editPanel={},a.workspace.collapsibleDetailPanels.status.editPanel.open=!1,a.workspace.collapsibleDetailPanels.status.possibleStatusList=[];var d=["development"],e=["production"],f=["deprecated","superseeded"];a.toggleEditStatus=function(){b.search().editingStatus?delete b.search().editingStatus:b.search().editingStatus=!0,b.search(b.search())},a.workspace.collapsibleDetailPanels.status.updateEditPanel=function(){b.search().editingStatus?a.schemaEditable?(a.workspace.collapsibleDetailPanels.status.possibleStatusList=a.selectedSchema["sc:schema"]["sc:access"]["sc:all"]&&"r"===a.selectedSchema["sc:schema"]["sc:access"]["sc:all"].actions?e.concat(f):d.concat(f),a.workspace.collapsibleDetailPanels.status.editPanel.open=!0):(delete b.search().editingStatus,b.search(b.search())):a.workspace.collapsibleDetailPanels.status.editPanel.open=!1,a.workspace.collapsibleDetailPanels.status.updateAjaxError=!1},a.saveStatus=function(){var b=a.selectedSchema["sc:schema"]["sc:status"],d=new c;a.workspace.collapsibleDetailPanels.status.waitingForServerUpdate=!0,a.workspace.collapsibleDetailPanels.status.updateAjaxError=!1,d.status=b,d.$save({schemaID:a.selectedSchema["sc:schema"]["xml:id"],schemaField:"status"},function(b){void 0!==b["sc:response"]&&b["sc:response"]&&b["sc:response"].success?(a.selectedSchema["sc:schema"]["sc:status"]=fixEmptyFields(b["sc:response"]["sc:written-data"]["sc:status"]),a.schemasList[a.selectedSchemaIndex]["sc:status"]=a.selectedSchema["sc:schema"]["sc:status"],a.workspace.collapsibleDetailPanels.status.editForm.$setPristine(),a.workspace.collapsibleDetailPanels.status.waitingForServerUpdate=!1):(a.workspace.collapsibleDetailPanels.status.waitingForServerUpdate=!1,a.workspace.collapsibleDetailPanels.status.updateAjaxError=!0)},function(){a.workspace.collapsibleDetailPanels.status.waitingForServerUpdate=!1,a.workspace.collapsibleDetailPanels.status.updateAjaxError=!0})}}]),SCHEMAcat.controller("AccessDetailsPanelCtrl",["$scope","$location","Schema",function(a,b,c){a.workspace.collapsibleDetailPanels.access={},a.workspace.collapsibleDetailPanels.access.editPanel={},a.workspace.collapsibleDetailPanels.access.editPanel.open=!1,a.currentAccessPolicy="",a.toggleEditAccess=function(){b.search().editingAccess?delete b.search().editingAccess:b.search().editingAccess=!0,b.search(b.search())},a.workspace.collapsibleDetailPanels.access.updateEditPanel=function(){b.search().editingAccess?a.schemaEditable?(a.currentAccessPolicy=a.workspace.collapsibleDetailPanels.access.getAccessPolicy(),a.workspace.collapsibleDetailPanels.access.editPanel.open=!0):(delete b.search().editingAccess,b.search(b.search())):a.workspace.collapsibleDetailPanels.access.editPanel.open=!1,a.workspace.collapsibleDetailPanels.access.updateAjaxError=!1},a.workspace.collapsibleDetailPanels.access.getAccessPolicy=function(){return void 0!==a.selectedSchema["sc:schema"]["sc:access"]["sc:all"]&&"r"===a.selectedSchema["sc:schema"]["sc:access"]["sc:all"].actions?"shareURL":"private"},a.saveAccessStatus=function(b){var d=a.selectedSchema["sc:schema"]["sc:access"]["sc:user"],e=new c;switch(a.workspace.collapsibleDetailPanels.access.waitingForServerUpdate=!0,a.workspace.collapsibleDetailPanels.access.updateAjaxError=!1,b){case"shareURL":e.access={all:{actions:"r"},user:d};break;case"private":e.access={user:d}}e.$save({schemaID:a.selectedSchema["sc:schema"]["xml:id"],schemaField:"access"},function(b){void 0!==b["sc:response"]&&b["sc:response"]&&b["sc:response"].success?(a.selectedSchema["sc:schema"]["sc:access"]=b["sc:response"]["sc:written-data"]["sc:access"],a.workspace.collapsibleDetailPanels.access.editForm.$setPristine(),a.workspace.collapsibleDetailPanels.access.waitingForServerUpdate=!1):(a.workspace.collapsibleDetailPanels.access.waitingForServerUpdate=!1,a.workspace.collapsibleDetailPanels.access.updateAjaxError=!0),a.currentAccessPolicy=a.workspace.collapsibleDetailPanels.access.getAccessPolicy()},function(){a.workspace.collapsibleDetailPanels.access.waitingForServerUpdate=!1,a.workspace.collapsibleDetailPanels.access.updateAjaxError=!0,a.currentAccessPolicy=a.workspace.collapsibleDetailPanels.access.getAccessPolicy()})}}]),SCHEMAcat.controller("LicenseDetailsPanelCtrl",["$scope","$modal","$location","$timeout","Schema","Licenses",function(a,b,c,d,e,f){function i(){h=b.open({scope:a,templateUrl:"partials/editLicenseModal.html"}),h.result.then(function(){h=void 0},function(b){h=void 0,"dismiss"!==b&&a.triggerCloseModalRoute()})}a.workspace.collapsibleDetailPanels.license={},a.input={};var g,h;a.filterLicenses=function(b){var c=new RegExp(a.workspace.collapsibleDetailPanels.license.editForm.filterTerm.$modelValue,"i");return b["sc:full-name"].match(c)||b["xml:id"].match(c)||void 0===a.workspace.collapsibleDetailPanels.license.editForm.filterTerm.$modelValue?!0:!1},a.showSelectedLicense=function(b){a.selectedSchema["sc:schema"]["sc:license"]["xml:id"]!==b["xml:id"]&&(a.workspace.collapsibleDetailPanels.license.modelDirty=!0,a.workspace.collapsibleDetailPanels.license.updatingLicense=!0,d(function(){a.selectedSchema["sc:schema"]["sc:license"]=b,a.workspace.collapsibleDetailPanels.license.updatingLicense=!1},250))},a.saveNewLicense=function(){var b=a.selectedSchema["sc:schema"]["sc:license"],c=new e;a.workspace.collapsibleDetailPanels.license.waitingForServerUpdate=!0,a.workspace.collapsibleDetailPanels.license.updateAjaxError=!1,c.license=b["xml:id"],c.$save({schemaID:a.selectedSchema["sc:schema"]["xml:id"],schemaField:"license"},function(b){void 0!==b["sc:response"]&&b["sc:response"]&&b["sc:response"].success&&b["sc:response"]["sc:written-data"]["sc:license"].ref===a.selectedSchema["sc:schema"]["sc:license"]["xml:id"]?(g=a.selectedSchema["sc:schema"]["sc:license"],a.workspace.collapsibleDetailPanels.license.modelDirty=!1,a.workspace.collapsibleDetailPanels.license.editForm.$setPristine(),a.workspace.collapsibleDetailPanels.license.waitingForServerUpdate=!1,a.triggerCloseModalRoute()):(a.workspace.collapsibleDetailPanels.license.waitingForServerUpdate=!1,a.workspace.collapsibleDetailPanels.license.updateAjaxError=!0)},function(){a.selectedSchema["sc:schema"]["sc:license"]=g,a.workspace.collapsibleDetailPanels.license.waitingForServerUpdate=!1,a.workspace.collapsibleDetailPanels.license.updateAjaxError=!0})},a.triggerOpenModalRoute=function(){c.search().editingLicense||(c.search().editingLicense=!0,c.search(c.search()))},a.triggerCloseModalRoute=function(){c.search().editingLicense&&(delete c.search().editingLicense,c.search(c.search()))},a.workspace.collapsibleDetailPanels.license.updateEditPanel=function(){c.search().editingLicense?a.schemaEditable?(void 0===g&&(g=a.selectedSchema["sc:schema"]["sc:license"]),void 0===a.workspace.collapsibleDetailPanels.license.licenseList&&(a.workspace.collapsibleDetailPanels.license.licensesArrived=!1,f.get(function(b){a.workspace.collapsibleDetailPanels.license.licenseList=b;for(var c=0;c<b["sc:licenses"]["sc:license"].length;c++)b["sc:licenses"]["sc:license"][c]["xml:id"]===a.selectedSchema["sc:schema"]["sc:license"]["xml:id"]&&(a.input.model=a.workspace.collapsibleDetailPanels.license.licenseList["sc:licenses"]["sc:license"][c]["xml:id"]);a.workspace.collapsibleDetailPanels.license.licensesArrived=!0})),i()):(a.workspace.collapsibleDetailPanels.license.editButtonTooltip="Change schema license",a.workspace.collapsibleDetailPanels.license.editForm&&a.workspace.collapsibleDetailPanels.license.modelDirty&&(a.workspace.collapsibleDetailPanels.license.editButtonTooltip+=" (there are unsaved changes in this field!)"),a.triggerCloseModalRoute()):void 0!==h&&h.dismiss("dismiss"),a.workspace.collapsibleDetailPanels.license.editButtonTooltip="Change schema license",a.workspace.collapsibleDetailPanels.license.editForm&&a.workspace.collapsibleDetailPanels.license.modelDirty&&(a.workspace.collapsibleDetailPanels.license.editButtonTooltip+=" (there are unsaved changes in this field!)")},a.cancelEdit=function(){a.workspace.collapsibleDetailPanels.license.modelDirty&&(a.workspace.collapsibleDetailPanels.license.updatingLicense=!0,a.workspace.collapsibleDetailPanels.license.modelDirty=!1,d(function(){a.selectedSchema["sc:schema"]["sc:license"]=g,a.workspace.collapsibleDetailPanels.license.updatingLicense=!1},250),a.workspace.collapsibleDetailPanels.license.editForm.$setPristine()),a.triggerCloseModalRoute()}}]),SCHEMAcat.controller("FileController",["$scope","$http","$timeout","$location",function(a,b,c,d){function e(){void 0!==d.search().show&&-1!==d.search().show.indexOf(a.file["sc:name"])?(a.showSchemaBtn=!0,f(a.selectedSchema["sc:schema"]["xml:id"],a.file["sc:name"])):(a.showSchemaBtn=!1,a.file.open=!1)}function f(d,e){void 0===a.schemaFileContent?b.get("/schemacat/schemas/"+d+"/files/"+e).success(function(b){a.prettify="prettyprint linenums",c(function(){prettyPrint(),a.file.open=!0}),a.schemaFileContent=b}).error(function(){a.showSchemaBtn=!1,a.showFile(e),a.showFileAjaxError=!0}):a.file.open=!0}e(),a.showFile=function(b){a.showFileAjaxError=!1,c(function(){var c=d.search();if(a.showSchemaBtn===!0)void 0===c.show?c.show="#"+b:-1===c.show.indexOf(b)&&(c.show=c.show+"#"+b);else for(var e in c)if("show"===e){var f=c[e].split("#");for(var g in f)f[g]===b&&f.splice(g,1);var h=f.join("#");""!==h?c[e]=h:delete c[e]}d.search(c)})},a.$on("$routeUpdate",function(){a.resultHasArrived&&e()})}]),SCHEMAcat.controller("TopMenuCtrl",["$scope","$modal","$location","UserService","Settings","ShibService",function(a,b,c,d,e,f){function g(){a.topMenuCollapsed=!c.search().topMenuExpanded,e.setAnimationStatus(!c.search().animationsDisabled),a.animationsChecked=e.getAnimationStatus()}a.displayName=d.displayName,a.shibURL=f.url,a.$watch(function(){return d.displayName},function(b,c){b!==c&&(a.displayName=b)}),g(),a.isActive=function(a){return"/workspace.html"===a&&-1!==c.path().indexOf("/workspace.html/")?!0:a===c.path()},a.updateAnimationStatus=function(){c.search().animationsDisabled?delete c.search().animationsDisabled:c.search().animationsDisabled=!0,c.search(c.search())},a.toggleTopMenu=function(){c.search().topMenuExpanded?delete c.search().topMenuExpanded:c.search().topMenuExpanded=!0,c.search(c.search())},a.animationsUrlPart=function(){return c.search().animationsDisabled?"animationsDisabled":""},a.topMenuExpandedUrlPart=function(){return c.search().topMenuExpanded?"topMenuExpanded":""},a.$on("$routeUpdate",function(){g()}),a.loginClick=function(){var c=b.open({scope:a,templateUrl:"partials/loginModal.html",controller:"LoginModalCtrl"});c.result.then(function(a){alert("Now set the user cookie to ["+a+"]"),document.cookie="USER="+a+";domain=;path=/",document.location.hash="",document.location.reload(!0)})}}]),SCHEMAcat.controller("LoginModalCtrl",["$scope","$modalInstance",function(a,b){a.loginClose=function(){b.dismiss("cancel")},a.loginSubmit=function(){b.close(this.loginNameInput.text)}}]),SCHEMAcat.controller("AboutPageCtrl",["$scope","Settings",function(a,b){a.$parent.toNextPage=!1,b.getAnimationStatus()&&(a.animateInOut="animated slideInRight"),a.$on("$routeChangeStart",function(c,d){if(b.getAnimationStatus())switch(d.templateUrl){case"partials/workspace.html":a.animateInOut="animated slideOutRight";break;case"partials/contact.html":a.animateInOut="animated slideOutLeft";break;default:a.animateInOut="animated fadeOutDown"}}),a.$on("$routeChangeSuccess",function(c,d,e){if(b.getAnimationStatus()){var f=void 0!==e?e.templateUrl:void 0;switch(f){case"partials/workspace.html":a.animateInOut="animated slideInRight";break;case"partials/contact.html":a.animateInOut="animated slideInLeft";break;default:a.animateInOut="animated fadeInDown"}}})}]),SCHEMAcat.controller("ContactPageCtrl",["$scope","Settings",function(a,b){a.$parent.toNextPage=!1,b.getAnimationStatus()&&(a.animateInOut="animated slideInRight"),a.$on("$routeChangeStart",function(c,d){if(b.getAnimationStatus())switch(d.templateUrl){case"partials/about.html":case"partials/contact.html":case"partials/workspace.html":a.animateInOut="animated slideOutRight";break;default:a.animateInOut="animated fadeOutDown"}}),a.$on("$routeChangeSuccess",function(c,d,e){if(b.getAnimationStatus()){var f=void 0!==e?e.templateUrl:void 0;switch(f){case"partials/about.html":case"partials/contact.html":case"partials/workspace.html":a.animateInOut="animated slideInRight";break;default:a.animateInOut="animated fadeInDown"}}})}]),SCHEMAcat.controller("AccountDetailsPageCtrl",["$scope","$location","User","UserService","Settings",function(a,b,c,d,e){function f(){var a=b.search();for(var c in a)if("editingEmail"===c){for(var e=a[c].split("#"),f=0;f<e.length;f++){for(var g=!1,h=0;h<d.email.length;h++)e[f]===d.email[h]&&(g=!0);g||e.splice(f,1)}var i=e.join("#");""!==i?a[c]=i:delete a[c]}b.search(a)}function g(){a.waitingForServerEditDisplayName=!1,a.editDisplayNameAjaxError=!1,b.search().editingDisplayName?(a.editDisplayNameText=a.displayName,a.editingDisplayName=!0):a.editingDisplayName=!1}function h(){a.waitingForServer=!1,a.addingEmail=b.search().addingEmail?!0:!1}a.principal=d.principal,a.displayName=d.displayName,a.email=d.email,a.addingEmail=!1,a.addNewEmail=function(){b.search().addingEmail=!0,b.search(b.search())},a.terminateAddEmail=function(){a.ajaxError=!1,delete b.search().addingEmail,b.search(b.search())},a.addEmail=function(b){a.waitingForServer=!0;var e=new c;e.emails=d.email.slice(0),e.emails.push(b),e.$save({userID:d.id},function(c){void 0!==c["sc:response"]&&c["sc:response"]&&c["sc:response"].success?(d.email.push(b),a.terminateAddEmail()):(a.waitingForServer=!1,a.ajaxError=!0)},function(){a.waitingForServer=!1,a.ajaxError=!0})},a.editDisplayName=function(){b.search().editingDisplayName=!0,b.search(b.search())},a.terminateEditDisplayName=function(){delete b.search().editingDisplayName,b.search(b.search())},a.updateDisplayName=function(b){a.waitingForServerEditDisplayName=!0;var e=new c;e.displayName=b,e.$save({userID:d.id},function(c){void 0!==c["sc:response"]&&c["sc:response"]&&c["sc:response"].success?(a.displayName=d.displayName=b,a.terminateEditDisplayName()):(a.waitingForServerEditDisplayName=!1,a.editDisplayNameAjaxError=!0)},function(){a.waitingForServerEditDisplayName=!1,a.editDisplayNameAjaxError=!0})},e.getAnimationStatus()&&(a.animateAccountDetails="animated fadeInDown"),a.$on("$routeChangeStart",function(){e.getAnimationStatus()&&(a.animateAccountDetails="animated fadeOutUp")}),a.$on("$routeChangeSuccess",function(){e.getAnimationStatus()&&(a.animateAccountDetails="animated fadeInDown"),h(),g(),f()}),a.$on("$routeUpdate",function(){h(),g(),f()})}]),SCHEMAcat.controller("EmailInstanceCtrl",["$scope","$location","User","UserService",function(a,b,c,d){function e(){a.waitingForServerEditEmail=!1,void 0!==b.search().editingEmail&&-1!==b.search().editingEmail.indexOf(a.emailInstance)?(a.editEmailText=a.emailInstance,a.editingEmail=!0):a.editingEmail=!1}e(),a.editEmail=function(c){var d=b.search();a.removeEmailAjaxError=!1,d.editingEmail=void 0===d.editingEmail?c:b.search().editingEmail+"#"+c,b.search(d)},a.removeEmail=function(b){a.waitingForServerEditEmail=!0;var e=new c;e.emails=d.email.slice(0),e.emails.splice(b,1),e.$save({userID:d.id},function(c){void 0!==c["sc:response"]&&c["sc:response"]&&c["sc:response"].success?d.email.splice(b,1):(a.waitingForServerEditEmail=!1,a.removeEmailAjaxError=!0)},function(){a.waitingForServerEditEmail=!1,a.removeEmailAjaxError=!0})},a.updateEmail=function(b){a.waitingForServerEditEmail=!0;var e=new c;e.emails=d.email.slice(0),e.emails[b]=a.editEmailText,e.$save({userID:d.id},function(c){if(void 0!==c["sc:response"]&&c["sc:response"]&&c["sc:response"].success){var e=a.editEmailText;a.cancelEditEmail(d.email[b]),d.email[b]=e}else a.waitingForServerEditEmail=!1,a.editEmailAjaxError=!0},function(){a.waitingForServerEditEmail=!1,a.editEmailAjaxError=!0})},a.cancelEditEmail=function(c){var d=b.search();a.editEmailAjaxError=!1;for(var e in d)if("editingEmail"===e){var f=d[e].split("#");for(var g in f)f[g]===c&&f.splice(g,1);var h=f.join("#");""!==h?d[e]=h:delete d[e]}b.search(d)},a.$on("$routeChangeSuccess",function(){e()}),a.$on("$routeUpdate",function(){e()})}]),SCHEMAcat.controller("CompleteUserDetailsCtrl",["$scope","$modal",function(a,b){a.ajaxError=!1,a.waitingForServer=!1,b.open({scope:a,backdrop:"static",keyboard:!1,templateUrl:"partials/fillDetailsModal.html",controller:"CompleteUserDetailsModalCtrl"})}]),SCHEMAcat.controller("CompleteUserDetailsModalCtrl",["$scope","$modalInstance","User","UserService",function(a,b,c,d){a.userDetailsSubmit=function(){a.waitingForServer=!0,a.ajaxError=!1;var b=new c;b.emails=[],b.emails[0]=this.emailInput.text,b.displayName=this.displayNameInput.text,b.$save({userID:d.id},function(b){void 0!==b["sc:response"]&&b["sc:response"]&&b["sc:response"].success?document.location.pathname="schemacat/site/index.html":(a.waitingForServer=!1,a.ajaxError=!0)},function(){a.waitingForServer=!1,a.ajaxError=!0})}}]);
