Changeset 4372


Ignore:
Timestamp:
01/28/14 17:35:32 (10 years ago)
Author:
andmor
Message:

Added to the UI the functionality to modify the schema access policy.

Location:
cats/SCHEMAcat/trunk/urn.org.isocat.schemacat.site/site
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • cats/SCHEMAcat/trunk/urn.org.isocat.schemacat.site/site/partials/accountDetails.html

    r4300 r4372  
    1616                                    <span data-ng-bind="displayName"></span>
    1717                                    <span>
    18                                         <button data-ng-click="editDisplayName()" class="btn btn-info btn-xs" data-ng-if="displayName != 'guest'"><i class="icon-edit"></i> Edit</button>
     18                                        <button data-ng-click="editDisplayName()" class="btn btn-info btn-xs" data-ng-if="displayName != 'guest'"><i class="glyphicon glyphicon-edit"></i> Edit</button>
    1919                                    </span>
    2020                                </p>
     
    2424                                            <input name="editDisplayNameInput" class="form-control" type="text" required="required" data-ng-model="editDisplayNameText"/>
    2525                                        </div>
    26                                         <button data-ng-click="updateDisplayName(editDisplayNameText)" class="btn btn-success btn-xs" data-ng-disabled="editDisplayNameForm.$invalid || waitingForServerEditDisplayName"><i class="icon-check"></i> Save</button>
    27                                         <button data-ng-click="terminateEditDisplayName()" class="btn btn-danger btn-xs"><i class="icon-remove"></i> Cancel</button>
     26                                        <button data-ng-click="updateDisplayName(editDisplayNameText)" class="btn btn-success btn-xs" data-ng-disabled="editDisplayNameForm.$invalid || waitingForServerEditDisplayName"><i class="glyphicon glyphicon-check"></i> Save</button>
     27                                        <button data-ng-click="terminateEditDisplayName()" class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-remove"></i> Cancel</button>
    2828                                        <img src="images/spinner-small.gif" alt="Loading..." data-ng-if="waitingForServerEditDisplayName"/>
    2929                                        <div class="col-md-12 has-error small" data-ng-if="editDisplayNameForm.editDisplayNameInput.$dirty &amp;&amp; editDisplayNameForm.editDisplayNameInput.$invalid">
     
    4848                                        <span data-ng-bind="emailInstance"></span>
    4949                                        <span>
    50                                             <button data-ng-click="editEmail(emailInstance)" class="btn btn-info btn-xs"><i class="icon-edit"></i> Edit</button>
    51                                             <button data-ng-click="removeEmail($index)" class="btn btn-danger btn-xs" data-ng-if="email.length &gt; 1"><i class="icon-remove"></i> Remove</button>
     50                                            <button data-ng-click="editEmail(emailInstance)" class="btn btn-info btn-xs"><i class="glyphicon glyphicon-edit"></i> Edit</button>
     51                                            <button data-ng-click="removeEmail($index)" class="btn btn-danger btn-xs" data-ng-if="email.length &gt; 1"><i class="glyphicon glyphicon-remove"></i> Remove</button>
    5252                                            <img src="images/spinner-small.gif" alt="Loading..." data-ng-if="waitingForServerEditEmail"/>
    5353                                        </span>
     
    6565                                                <input name="editEmailInput" class="form-control" type="email" required="required" data-ng-model="$parent.editEmailText"/>
    6666                                            </div>
    67                                             <button data-ng-click="updateEmail($index)" class="btn btn-success btn-xs" data-ng-disabled="editEmailForm.$invalid || waitingForServerEditEmail"><i class="icon-check"></i> Save</button>
    68                                             <button data-ng-click="cancelEditEmail(emailInstance)" class="btn btn-danger btn-xs"><i class="icon-remove"></i> Cancel</button>
     67                                            <button data-ng-click="updateEmail($index)" class="btn btn-success btn-xs" data-ng-disabled="editEmailForm.$invalid || waitingForServerEditEmail"><i class="glyphicon glyphicon-check"></i> Save</button>
     68                                            <button data-ng-click="cancelEditEmail(emailInstance)" class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-remove"></i> Cancel</button>
    6969                                            <img src="images/spinner-small.gif" alt="Loading..." data-ng-if="waitingForServerEditEmail"/>
    7070                                            <span class="col-md-12 has-error small" data-ng-show="editEmailForm.editEmailInput.$dirty &amp;&amp; editEmailForm.editEmailInput.$invalid">
     
    9595                                                <input name="newEmailInput" class="form-control" type="email" required="required" data-ng-model="newEmailInputText"/>
    9696                                            </div>
    97                                             <button data-ng-click="addEmail(newEmailInputText)" class="btn btn-success btn-xs" data-ng-disabled="newEmailForm.$invalid || waitingForServer"><i class="icon-check"></i> Save</button>
    98                                             <button data-ng-click="terminateAddEmail()" class="btn btn-danger btn-xs"><i class="icon-remove"></i> Cancel</button>
     97                                            <button data-ng-click="addEmail(newEmailInputText)" class="btn btn-success btn-xs" data-ng-disabled="newEmailForm.$invalid || waitingForServer"><i class="glyphicon glyphicon-check"></i> Save</button>
     98                                            <button data-ng-click="terminateAddEmail()" class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-remove"></i> Cancel</button>
    9999                                            <img src="images/spinner-small.gif" alt="Loading..." data-ng-if="waitingForServer"/>
    100100                                            <span class="col-md-12 has-error small" data-ng-if="newEmailForm.newEmailInput.$dirty &amp;&amp; newEmailForm.newEmailInput.$invalid">
  • cats/SCHEMAcat/trunk/urn.org.isocat.schemacat.site/site/partials/workspace.html

    r4300 r4372  
    4141                    <p data-ng-if="selectedSchema['sc:schema']['sc:description'] == '[object Object]'">--</p>
    4242                    <div class="row">
    43                         <div class="col-md-2">
     43                        <div class="col-sm-2">
    4444                            <h4>Version:</h4>
    4545                            <p data-ng-if="selectedSchema['sc:schema']['sc:version'] != '[object Object]'" data-ng-bind="selectedSchema['sc:schema']['sc:version']"/>
    4646                            <p data-ng-if="selectedSchema['sc:schema']['sc:version'] == '[object Object]'">--</p>
    4747                        </div>
    48                         <div class="col-md-2">
     48                        <div class="col-sm-2">
    4949                            <h4>Status:</h4>
    5050                            <p data-ng-if="selectedSchema['sc:schema']['sc:status'] != '[object Object]'" data-ng-bind="selectedSchema['sc:schema']['sc:status']"/>
    5151                            <p data-ng-if="selectedSchema['sc:schema']['sc:status'] == '[object Object]'">--</p>
    5252                        </div>
    53                         <div class="col-md-2">
     53                        <div class="col-sm-3" data-ng-init="accessDetailsPanel.open = false;">
    5454                            <h4>Access:</h4>
    55                             <p data-ng-if="selectedSchema['sc:schema']['sc:access']['sc:all']['actions'] == 'r'">shared URL</p>
    56                             <p data-ng-if="selectedSchema['sc:schema']['sc:access']['sc:all']['actions'] != 'r'">private</p>
     55                            <div data-collapse="workspace.waitingForServerAccessStatusUpdate">
     56                                <p data-ng-if="selectedSchema['sc:schema']['sc:access']['sc:all']['actions'] == 'r'">
     57                                    <span>shared URL&nbsp;</span>
     58                                    <small id="access-actions">
     59                                        <span data-ng-show="!accessDetailsPanel.open" class="word-breaking-wraper">
     60                                            <a data-tooltip="Show access policy details" data-tooltip-popup-delay="750"
     61                                                data-tooltip-placement="top" data-ng-click="toggleAccessDetails()" class="cursor-pointer"><i class="glyphicon glyphicon-collapse-down"></i></a>
     62                                        </span>
     63                                        <span data-ng-show="accessDetailsPanel.open" class="word-breaking-wraper">
     64                                            <a data-tooltip="Hidde access policy details" data-tooltip-popup-delay="750"
     65                                                data-tooltip-placement="bottom" data-ng-click="toggleAccessDetails()" class="cursor-pointer"><i class="glyphicon glyphicon-collapse-up"></i></a>
     66                                        </span>
     67                                    </small>
     68                                </p>
     69                                <p data-ng-if="selectedSchema['sc:schema']['sc:access']['sc:all']['actions'] != 'r'">
     70                                    <span>private&nbsp;&nbsp;</span>
     71                                    <small id="access-actions">
     72                                        <span data-ng-show="!accessDetailsPanel.open" class="word-breaking-wraper">
     73                                            <a data-tooltip="Show access policy details" data-tooltip-popup-delay="750"
     74                                                data-tooltip-placement="top" data-ng-click="toggleAccessDetails()" class="cursor-pointer"><i class="glyphicon glyphicon-collapse-down"></i></a>
     75                                        </span>
     76                                        <span data-ng-show="accessDetailsPanel.open" class="word-breaking-wraper">
     77                                            <a data-tooltip="Hidde access policy details" data-tooltip-popup-delay="750"
     78                                                data-tooltip-placement="bottom" data-ng-click="toggleAccessDetails()" class="cursor-pointer"><i class="glyphicon glyphicon-collapse-up"></i></a>
     79                                        </span>
     80                                    </small>
     81                                </p>
     82                            </div>
    5783                        </div>
    58                         <div class="col-md-2">
     84                        <div class="col-sm-2">
    5985                            <h4>License:</h4>
    6086                            <p data-ng-if="selectedSchema['sc:schema']['sc:license'] != undefined">
     
    6692                        </div>
    6793                    </div>
     94                    <div class="row col-md-12" data-ng-controller="accessDetailsPanelCtrl">
     95                        <div class="panel panel-primary small modal-title" data-collapse="!accessDetailsPanel.open">
     96                            <div class="panel-heading">
     97                                <label>Access policy:</label>
     98                            </div>
     99                            <div class="panel-body">
     100                                <div data-collapse="!editAccessPanel.open">
     101                                    <form name="workspace.editAccessForm" class="form-inline">
     102                                        <div class="form-group small">
     103                                            <label>Private</label>
     104                                            <input type="radio" data-ng-change="saveAccessStatus(workspace.editAccessForm.accessPolicy)" name="accessRadios" id="accessRadios1" data-ng-model="workspace.editAccessForm.accessPolicy" value="private" ></input>
     105                                            <span>&nbsp;</span>
     106                                            <label>Shared URL</label>
     107                                            <input type="radio" data-ng-change="saveAccessStatus(workspace.editAccessForm.accessPolicy)" name="accessRadios" id="accessRadios2" data-ng-model="workspace.editAccessForm.accessPolicy" value="shareURL"></input>
     108                                            <span data-ng-show="workspace.waitingForServerAccessStatusUpdate">
     109                                                &nbsp;&nbsp;<img src="images/spinner-small.gif" alt="Saving..."/>
     110                                            </span>
     111                                        </div>
     112                                    </form>
     113                                    <div class="form-group has-error">
     114                                        <span class="help-block" data-collapse="!workspace.accessStatusUpdateAjaxError">
     115                                            <div>The server responded with an error. Please try again!</div>
     116                                            <div>If the problem persists contact us at:</div>
     117                                            <div><a href="mailto:tla@mpi.nl">isocat@mpi.nl</a></div>
     118                                        </span>
     119                                    </div>
     120                                </div>
     121                                <p data-collapse="workspace.waitingForServerAccessStatusUpdate">
     122                                    <label>
     123                                        <span data-ng-hide="selectedSchema['sc:schema']['sc:access']['sc:all']['actions'] != 'r'">Shared URL&nbsp;&nbsp;</span>
     124                                        <span data-ng-show="selectedSchema['sc:schema']['sc:access']['sc:all']['actions'] != 'r'">Private&nbsp;&nbsp;</span>
     125                                        <a class="small cursor-pointer" data-ng-show="editAccessPanel.open" data-tooltip="Done" data-tooltip-popup-delay="750" data-ng-click="toggleEditAccess()">
     126                                            <i class="glyphicon glyphicon-chevron-up"></i>
     127                                        </a>
     128                                        <a class="small cursor-pointer" data-ng-hide="editAccessPanel.open" data-tooltip="Change access policy" data-tooltip-popup-delay="750" data-ng-click="toggleEditAccess()">
     129                                            <i class="glyphicon glyphicon-edit"></i>
     130                                        </a>
     131                                    </label>
     132                                </p>
     133                                <div data-collapse="workspace.waitingForServerAccessStatusUpdate">
     134                                    <div data-ng-show="selectedSchema['sc:schema']['sc:access']['sc:all']['actions'] == 'r'">
     135                                        <p>This schema is shared and its files can be accessed by anyone through the following public URL(s):</p>
     136                                        <ul>
     137                                            <li data-ng-repeat="file in filesList">{{location.protocol + '//' + location.host}}/schemacat/schemas/{{selectedSchema['sc:schema']['xml:id']}}/files/{{file['sc:name']}}</li>
     138                                        </ul>
     139                                    </div>
     140                                    <div data-ng-hide="selectedSchema['sc:schema']['sc:access']['sc:all']['actions'] == 'r'">
     141                                        <p>This schema is private to your workspace and cannot be accessed without authentication.</p>
     142                                    </div>
     143                                </div>
     144                            </div>
     145                        </div>
     146                    </div>
    68147                    <div class="row">
    69                         <div class="col-md-2">
     148                        <div class="col-sm-2">
    70149                            <h5>Group tags:</h5>
    71150                        </div>
    72                         <h6 data-ng-if="selectedSchema['sc:schema']['sc:tag']['content']" data-ng-bind=" '[' + selectedSchema['sc:schema']['sc:tag']['content'] + ']'"></h6>
     151                        <div class="col-sm-10">
     152                            <h6 data-ng-if="selectedSchema['sc:schema']['sc:tag']['content']" data-ng-bind=" '[' + selectedSchema['sc:schema']['sc:tag']['content'] + ']'"></h6>
     153                        </div>
    73154                    </div>
    74155                    <div>
     
    78159                                <span>
    79160                                    <span data-ng-bind="file['sc:name']"></span><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
    80                                     <button type="button" class="btn btn-success btn-xs" data-ng-model="showSchemaBtn" data-btn-checkbox="" data-ng-click="showFile(file['sc:name']);">
    81                                         <span data-ng-hide="showSchemaBtn">Show</span><span data-ng-show="showSchemaBtn">Hide</span>
    82                                     </button>
    83                                     <a href="/schemacat/schemas/{{selectedSchema['sc:schema']['xml:id']}}/files/{{file['sc:name']}}" class="btn btn-primary btn-xs">Open</a>
    84                                     <a href="/schemacat/schemas/{{selectedSchema['sc:schema']['xml:id']}}/download/files/{{file['sc:name']}}" class="btn btn-danger btn-xs" download>Download</a>
     161                                    <a class="btn btn-success btn-xs" data-ng-model="showSchemaBtn" data-btn-checkbox="" data-ng-click="showFile(file['sc:name'])">
     162                                        <span data-tooltip="Show file inline" data-tooltip-popup-delay="750" data-tooltip-append-to-body="true" data-ng-hide="showSchemaBtn"><i class="glyphicon glyphicon glyphicon-collapse-down"></i> Show</span><span data-tooltip="Hide file" data-tooltip-popup-delay="750" data-tooltip-append-to-body="true" data-ng-show="showSchemaBtn"><i class="glyphicon glyphicon glyphicon-collapse-up"></i> Hide</span>
     163                                    </a>
     164                                    <a data-tooltip="Navigate to file URL" data-tooltip-popup-delay="750" data-tooltip-append-to-body="true" href="/schemacat/schemas/{{selectedSchema['sc:schema']['xml:id']}}/files/{{file['sc:name']}}" class="btn btn-primary btn-xs"><i class="glyphicon glyphicon-share"></i> Open</a>
     165                                    <a data-tooltip="Download file" data-tooltip-popup-delay="750" data-tooltip-append-to-body="true" href="/schemacat/schemas/{{selectedSchema['sc:schema']['xml:id']}}/download/files/{{file['sc:name']}}" class="btn btn-danger btn-xs" download><i class="glyphicon glyphicon-download"></i> Download</a>
    85166                                    <span data-ng-show="showSchemaBtn &amp;&amp; !file.open">
    86167                                        <span>&nbsp;&nbsp;</span>
     
    92173                                </div>
    93174                                <div class="has-error small" data-ng-show="showFileAjaxError">
    94                                     <small class="help-block">
     175                                    <div class="help-block">
    95176                                        <div>The server responded with an error. Please try again!</div>
    96177                                        <div>If the problem persists contact us at:</div>
  • cats/SCHEMAcat/trunk/urn.org.isocat.schemacat.site/site/scripts/controllers.js

    r4300 r4372  
    44SCHEMAcat.controller('WorkspaceCtrl', ['$scope', '$location', '$routeParams', '$timeout', 'SchemasList', 'Schema', 'UserService', 'Settings',
    55    function($scope, $location, $routeParams, $timeout, SchemasList, Schema, UserService, Settings) {
     6
     7
     8        function prepareArrayForNgRepeat(data) {
     9            var array;
     10            if (data instanceof Array)
     11                array = data;
     12            else
     13                array = new Array(data);
     14            return array;
     15        }
     16
     17
     18        function loadSchemasList(page) {
     19            //check if pageNumber is not a number (can happen e.g. due to manual input)
     20            //reload on page 1 schema index 0 if so
     21            if (isNaN(parseInt(page, 10)) || page < 1) {
     22                $location.path('workspace/page/' + 1 + '/').search({
     23                    'schemaIndex': 0
     24                });
     25                return;
     26            }
     27
     28            //When the user changes page, the new AJAX data (next page) is requested by
     29            //the unloading controller (previous page) and used by the next loaded
     30            //controller (next page), thus we have to keep the server data across controller
     31            //reloads by saving it in the parent scope.
     32            SchemasList.get({
     33                    userID: UserService.id,
     34                    startPage: page,
     35                    pageSize: $scope.pageSize
     36                },
     37                function(result) {
     38                    //we now have the pages range so we can configure the paginator and check if pageNumber is out of
     39                    //range (can happen e.g. due to manual input) reload on page 1 schema index 0 if so
     40                    if (page > Math.ceil(result['sc:result']['sc:total-schemas'] / $scope.pageSize)) {
     41                        $location.path('workspace/page/' + 1 + '/').search({
     42                            'schemaIndex': 0
     43                        });
     44                        return;
     45                    }
     46
     47                    parentScope.totalSchemaItems = result['sc:result']['sc:total-schemas'];
     48                    parentScope.currentPage = Number(page);
     49
     50
     51                    //when there is just one element we create an array with it, so ng-repeat repeats just once
     52                    parentScope.schemasList = prepareArrayForNgRepeat(result['sc:result']['sc:schemas']['sc:schema']);
     53
     54                    loadSchemaMetadata($location.search().schemaIndex);
     55
     56                    parentScope.schemasResult = result;
     57                });
     58        }
     59
     60
     61        //loads (trough a 'Schema' AJAX call) the schema metadata of the schema placed
     62        //in the 'index' position of the schemas list.
     63        function loadSchemaMetadata(index) {
     64            //if just changing the selected schema hide the metadata pane until the metadata is loaded
     65            if ($scope.animateWorkspacePageChange !== 'invisible')
     66                $scope.animateSchemaChange = 'invisible';
     67            //check if schemaIndex is out of range (can happen e.g. due to manual input)
     68            //reload on schema index 0 if so
     69            if (isNaN(parseInt(index, 10)) || index < 0 || index > $scope.schemasList.length - 1) {
     70                $scope.selectedSchemaIndex = undefined;
     71                $location.search({
     72                    'schemaIndex': 0
     73                });
     74                return;
     75            }
     76            //update the selected row to the route search part.
     77            $scope.selectedSchemaIndex = index;
     78
     79            //make AJAX call to get the schema metadata for the selected row
     80            var selectedSchemaRow = parentScope.schemasList[Number(index)];
     81            Schema.get({
     82                    schemaID: selectedSchemaRow['xml:id']
     83                },
     84                function(result) {
     85                    //when there is just one element we create an array with it, so ng-repeat repeats just once
     86                    parentScope.filesList = prepareArrayForNgRepeat(result['sc:schema']['sc:files']['sc:file']);
     87
     88                    if (Settings.getAnimationStatus()) {
     89                        //fade in the schema metadata
     90                        switch ($scope.toNextSchema) {
     91                            case true:
     92                                $scope.animateSchemaChange = 'animated fadeInUp';
     93                                break;
     94                            case false:
     95                                $scope.animateSchemaChange = 'animated fadeInDown';
     96                                break;
     97                                //if it is a reload toNextPage will be undefined
     98                            case undefined:
     99                                $scope.animateSchemaChange = 'animated fadeInDown';
     100                        }
     101                    } else
     102                        $scope.animateSchemaChange = '';
     103
     104                    parentScope.selectedSchema = result;
     105                    updateAccessDetailsPanel();
     106                    parentScope.resultHasArrived = true;
     107                });
     108
     109        }
     110
     111
     112        function updateAccessDetailsPanel() {
     113            $scope.workspace.editAccessForm.accessPolicy = $scope.workspace.getAccessPolicy();
     114            if ($location.search().showAccessDetails) {
     115                $scope.accessDetailsPanel.open = true;
     116            } else
     117                $scope.accessDetailsPanel.open = false;
     118        }
    6119
    7120        //these models have to be stored in the parent scope since they are used across page changes and
     
    16129        $scope.animateWorkspacePageChange = 'invisible';
    17130
     131        $scope.workspace = {};
     132        $scope.location = location;
     133
     134        window.clipboardData = 'test';
    18135
    19136
     
    43160                    $scope.animateWorkspacePageChange = '';
    44161                //derregister the listener since the workspace page is now loaded
     162                updateAccessDetailsPanel();
    45163                watchListener();
    46164            }
     
    68186            $location.search().schemaIndex = rowIndex.toString();
    69187            delete $location.search().show;
     188            $location.search($location.search());
     189        };
     190
     191        $scope.toggleAccessDetails = function() {
     192            $scope.accessDetailsPanel.open = !$scope.accessDetailsPanel.open;
     193            if (!$scope.accessDetailsPanel.open)
     194                delete $location.search().showAccessDetails;
     195            else
     196                $location.search().showAccessDetails = true;
     197
    70198            $location.search($location.search());
    71199        };
     
    135263        });
    136264
    137 
    138         function loadSchemasList(page) {
    139             //check if pageNumber is not a number (can happen e.g. due to manual input)
    140             //reload on page 1 schema index 0 if so
    141             if (isNaN(parseInt(page, 10))  || page < 1) {
    142                 $location.path('workspace/page/' + 1 + '/').search({
    143                     'schemaIndex': 0
    144                 });
    145                 return;
    146             }
    147 
    148             //When the user changes page, the new AJAX data (next page) is requested by
    149             //the unloading controller (previous page) and used by the next loaded
    150             //controller (next page), thus we have to keep the server data across controller
    151             //reloads by saving it in the parent scope.
    152             SchemasList.get({
    153                     userID: UserService.id,
    154                     startPage: page,
    155                     pageSize: $scope.pageSize
     265        parentScope.workspaceFirstLoaded = true;
     266    }
     267]);
     268
     269SCHEMAcat.controller('accessDetailsPanelCtrl', ['$scope', '$location', 'Schema',
     270    function($scope, $location, Schema) {
     271
     272        var parentScope = $scope.$parent;
     273        parentScope.editAccessPanel = {};
     274
     275        function updateEditAccessPanel() {
     276            if ($location.search().edditingAccess) {
     277                parentScope.editAccessPanel.open = true;
     278            } else
     279                parentScope.editAccessPanel.open = false;
     280            $scope.workspace.accessStatusUpdateAjaxError = false;
     281        }
     282
     283        $scope.toggleEditAccess = function() {
     284            parentScope.editAccessPanel.open = !parentScope.editAccessPanel.open;
     285            if (!parentScope.editAccessPanel.open)
     286                delete $location.search().edditingAccess;
     287            else
     288                $location.search().edditingAccess = true;
     289
     290            $location.search($location.search());
     291        };
     292
     293        $scope.workspace.getAccessPolicy = function() {
     294            if (parentScope.selectedSchema['sc:schema']['sc:access']['sc:all'] !== undefined && parentScope.selectedSchema['sc:schema']['sc:access']['sc:all'].actions === 'r')
     295                return 'shareURL';
     296            else
     297                return 'private';
     298        };
     299
     300        $scope.saveAccessStatus = function(newAccessStatus) {
     301            var accessUser = $scope.selectedSchema['sc:schema']['sc:access']['sc:user'];
     302            var schema = new Schema();
     303            $scope.workspace.waitingForServerAccessStatusUpdate = true;
     304            $scope.workspace.accessStatusUpdateAjaxError = false;
     305
     306            switch (newAccessStatus) {
     307                case 'shareURL':
     308                    schema.access = {
     309                        'all': {
     310                            'actions': 'r'
     311                        },
     312                        'user': accessUser
     313                    };
     314                    break;
     315                case 'private':
     316                    schema.access = {
     317                        'user': accessUser
     318                    };
     319                    break;
     320            }
     321
     322            schema.$save({
     323                    schemaID: $scope.schemasList[$scope.selectedSchemaIndex]['xml:id'],
     324                    schemaField: 'access'
    156325                },
    157326                function(result) {
    158                     //we now have the pages range so we can configure the paginator and check if pageNumber is out of
    159                     //range (can happen e.g. due to manual input) reload on page 1 schema index 0 if so
    160                     if (page > Math.ceil(result['sc:result']['sc:total-schemas'] / $scope.pageSize)) {
    161                         $location.path('workspace/page/' + 1 + '/').search({
    162                             'schemaIndex': 0
    163                         });
    164                         return;
    165                     }
    166 
    167                     parentScope.totalSchemaItems = result['sc:result']['sc:total-schemas'];
    168                     parentScope.currentPage = Number(page);
    169 
    170 
    171                     //when there is just one element we create an array with it, so ng-repeat repeats just once
    172                     parentScope.schemasList = prepareArrayForNgRepeat(result['sc:result']['sc:schemas']['sc:schema']);
    173 
    174                     loadSchemaMetadata($location.search().schemaIndex);
    175 
    176                     parentScope.schemasResult = result;
    177                 });
    178         }
    179 
    180 
    181         //loads (trough a 'Schema' AJAX call) the schema metadata of the schema placed
    182         //in the 'index' position of the schemas list.
    183         function loadSchemaMetadata(index) {
    184             //if just changing the selected schema hide the metadata pane until the metadata is loaded
    185             if ($scope.animateWorkspacePageChange !== 'invisible')
    186                 $scope.animateSchemaChange = 'invisible';
    187             //check if schemaIndex is out of range (can happen e.g. due to manual input)
    188             //reload on schema index 0 if so
    189             if (isNaN(parseInt(index, 10)) || index < 0 || index > $scope.schemasList.length - 1) {
    190                 $scope.selectedSchemaIndex = undefined;
    191                 $location.search({
    192                     'schemaIndex': 0
    193                 });
    194                 return;
    195             }
    196             //update the selected row to the route search part.
    197             $scope.selectedSchemaIndex = index;
    198 
    199             //make AJAX call to get the schema metadata for the selected row
    200             var selectedSchemaRow = parentScope.schemasList[Number(index)];
    201             Schema.get({
    202                     schemaID: selectedSchemaRow['xml:id']
    203                 },
    204                 function(result) {
    205                     //when there is just one element we create an array with it, so ng-repeat repeats just once
    206                     parentScope.filesList = prepareArrayForNgRepeat(result['sc:schema']['sc:files']['sc:file']);
    207 
    208                     if (Settings.getAnimationStatus()) {
    209                         //fade in the schema metadata
    210                         switch ($scope.toNextSchema) {
    211                             case true:
    212                                 $scope.animateSchemaChange = 'animated fadeInUp';
    213                                 break;
    214                             case false:
    215                                 $scope.animateSchemaChange = 'animated fadeInDown';
    216                                 break;
    217                                 //if it is a reload toNextPage will be undefined
    218                             case undefined:
    219                                 $scope.animateSchemaChange = 'animated fadeInDown';
    220                         }
    221                     } else
    222                         $scope.animateSchemaChange = '';
    223 
    224                     parentScope.selectedSchema = result;
    225                     parentScope.resultHasArrived = true;
    226                 });
    227 
    228         }
    229 
    230         function prepareArrayForNgRepeat(data) {
    231             var array;
    232             if (data instanceof Array)
    233                 array = data;
    234             else
    235                 array = new Array(data);
    236             return array;
    237         }
    238 
    239         parentScope.workspaceFirstLoaded = true;
    240 
    241     }
    242 ]);
     327                    if (result['sc:response'] !== undefined && result['sc:response'].success) {
     328                        $scope.selectedSchema['sc:schema']['sc:access'] = result['sc:response']['sc:written-data']['sc:access'];
     329                        $scope.workspace.waitingForServerAccessStatusUpdate = false;
     330                    } else {
     331                        //server reports an handeled error
     332                        $scope.workspace.waitingForServerAccessStatusUpdate = false;
     333                        $scope.workspace.accessStatusUpdateAjaxError = true;
     334                    }
     335                    //refresh the view model
     336                    $scope.workspace.editAccessForm.accessPolicy = $scope.workspace.getAccessPolicy();
     337                },
     338                //no response, or response error flagged in http response headers
     339                function() {
     340                    $scope.workspace.waitingForServerAccessStatusUpdate = false;
     341                    $scope.workspace.accessStatusUpdateAjaxError = true;
     342                    $scope.workspace.editAccessForm.accessPolicy = $scope.workspace.getAccessPolicy();
     343                });
     344        };
     345
     346        $scope.$on('$routeUpdate', function(event, route) {
     347            updateEditAccessPanel();
     348        });
     349
     350        updateEditAccessPanel();
     351    }
     352]);
     353
    243354
    244355
  • cats/SCHEMAcat/trunk/urn.org.isocat.schemacat.site/site/scripts/controllers.min.js

    r4300 r4372  
    1 "use strict";SCHEMAcat.controller("WorkspaceCtrl",["$scope","$location","$routeParams","$timeout","SchemasList","Schema","UserService","Settings",function(a,b,c,d,e,f,g,h){function k(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):(i.totalSchemaItems=d["sc:result"]["sc:total-schemas"],i.currentPage=Number(c),i.schemasList=m(d["sc:result"]["sc:schemas"]["sc:schema"]),l(b.search().schemaIndex),i.schemasResult=d,void 0)}),void 0)}function l(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=i.schemasList[Number(c)];f.get({schemaID:d["xml:id"]},function(b){if(i.filesList=m(b["sc:schema"]["sc:files"]["sc:file"]),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="";i.selectedSchema=b,i.resultHasArrived=!0})}function m(a){var b;return b=a instanceof Array?a:new Array(a)}var i=a.$parent;i.pageSize=10,a.selectedSchemaIndex=c.schemaIndex,a.animateWorkspacePageChange="invisible";var j=a.$watch("resultHasArrived",function(b){if(b){if(h.getAnimationStatus()){switch(i.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="";j()}});i.workspaceFirstLoaded||k(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.$on("$routeChangeStart",function(b,c,d){if(i.resultHasArrived=!1,h.getAnimationStatus())switch(i.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=i.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?k(c.params.pageNumber):i.workspaceFirstLoaded=!1}),a.$on("$routeChangeSuccess",function(a,b,c){h.getAnimationStatus()&&(void 0===c||void 0===c.templateUrl||"partials/accountDetails.html"===c.templateUrl)&&(i.toNextPage=void 0)}),a.$on("$routeUpdate",function(b,c){"partials/workspace.html"===c.templateUrl&&c.params.schemaIndex!==a.selectedSchemaIndex&&(i.resultHasArrived=!1,h.getAnimationStatus()?(a.toNextSchema=c.params.schemaIndex>a.selectedSchemaIndex?!0:!1,a.animateSchemaChange=a.toNextSchema?"animated fadeOutUp":"animated fadeOutDown",d(function(){l(c.params.schemaIndex)},250)):l(c.params.schemaIndex))}),i.workspaceFirstLoaded=!0}]),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(){a.animationsChecked=!a.animationsChecked,a.animationsChecked?delete c.search().animationsDisabled:c.search().animationsDisabled=!0,c.search(c.search())},a.toggleTopMenu=function(){a.topMenuCollapsed=!a.topMenuCollapsed,a.topMenuCollapsed?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("edditingEmail"===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().edditingDisplayName?(a.editDisplayNameText=a.displayName,a.edditingDisplayName=!0):a.edditingDisplayName=!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"].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().edditingDisplayName=!0,b.search(b.search())},a.terminateEditDisplayName=function(){delete b.search().edditingDisplayName,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"].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().edditingEmail&&-1!==b.search().edditingEmail.indexOf(a.emailInstance)?(a.editEmailText=a.emailInstance,a.edditingEmail=!0):a.edditingEmail=!1}e(),a.editEmail=function(c){var d=b.search();a.removeEmailAjaxError=!1,d.edditingEmail=void 0===d.edditingEmail?c:b.search().edditingEmail+"#"+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"].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"].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("edditingEmail"===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",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"].success?document.location.pathname="schemacat/site/index.html":(a.waitingForServer=!1,a.ajaxError=!0)},function(){a.waitingForServer=!1,a.ajaxError=!0})}}]);
     1"use strict";SCHEMAcat.controller("WorkspaceCtrl",["$scope","$location","$routeParams","$timeout","SchemasList","Schema","UserService","Settings",function(a,b,c,d,e,f,g,h){function i(a){var b;return b=a instanceof Array?a:new Array(a)}function j(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):(m.totalSchemaItems=d["sc:result"]["sc:total-schemas"],m.currentPage=Number(c),m.schemasList=i(d["sc:result"]["sc:schemas"]["sc:schema"]),k(b.search().schemaIndex),m.schemasResult=d,void 0)}),void 0)}function k(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=m.schemasList[Number(c)];f.get({schemaID:d["xml:id"]},function(b){if(m.filesList=i(b["sc:schema"]["sc:files"]["sc:file"]),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="";m.selectedSchema=b,l(),m.resultHasArrived=!0})}function l(){a.workspace.editAccessForm.accessPolicy=a.workspace.getAccessPolicy(),a.accessDetailsPanel.open=b.search().showAccessDetails?!0:!1}var m=a.$parent;m.pageSize=10,a.selectedSchemaIndex=c.schemaIndex,a.animateWorkspacePageChange="invisible",a.workspace={},a.location=location,window.clipboardData="test";var n=a.$watch("resultHasArrived",function(b){if(b){if(h.getAnimationStatus()){switch(m.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(),n()}});m.workspaceFirstLoaded||j(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.toggleAccessDetails=function(){a.accessDetailsPanel.open=!a.accessDetailsPanel.open,a.accessDetailsPanel.open?b.search().showAccessDetails=!0:delete b.search().showAccessDetails,b.search(b.search())},a.$on("$routeChangeStart",function(b,c,d){if(m.resultHasArrived=!1,h.getAnimationStatus())switch(m.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=m.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?j(c.params.pageNumber):m.workspaceFirstLoaded=!1}),a.$on("$routeChangeSuccess",function(a,b,c){h.getAnimationStatus()&&(void 0===c||void 0===c.templateUrl||"partials/accountDetails.html"===c.templateUrl)&&(m.toNextPage=void 0)}),a.$on("$routeUpdate",function(b,c){"partials/workspace.html"===c.templateUrl&&c.params.schemaIndex!==a.selectedSchemaIndex&&(m.resultHasArrived=!1,h.getAnimationStatus()?(a.toNextSchema=c.params.schemaIndex>a.selectedSchemaIndex?!0:!1,a.animateSchemaChange=a.toNextSchema?"animated fadeOutUp":"animated fadeOutDown",d(function(){k(c.params.schemaIndex)},250)):k(c.params.schemaIndex))}),m.workspaceFirstLoaded=!0}]),SCHEMAcat.controller("accessDetailsPanelCtrl",["$scope","$location","Schema",function(a,b,c){function e(){d.editAccessPanel.open=b.search().edditingAccess?!0:!1,a.workspace.accessStatusUpdateAjaxError=!1}var d=a.$parent;d.editAccessPanel={},a.toggleEditAccess=function(){d.editAccessPanel.open=!d.editAccessPanel.open,d.editAccessPanel.open?b.search().edditingAccess=!0:delete b.search().edditingAccess,b.search(b.search())},a.workspace.getAccessPolicy=function(){return void 0!==d.selectedSchema["sc:schema"]["sc:access"]["sc:all"]&&"r"===d.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.waitingForServerAccessStatusUpdate=!0,a.workspace.accessStatusUpdateAjaxError=!1,b){case"shareURL":e.access={all:{actions:"r"},user:d};break;case"private":e.access={user:d}}e.$save({schemaID:a.schemasList[a.selectedSchemaIndex]["xml:id"],schemaField:"access"},function(b){void 0!==b["sc:response"]&&b["sc:response"].success?(a.selectedSchema["sc:schema"]["sc:access"]=b["sc:response"]["sc:written-data"]["sc:access"],a.workspace.waitingForServerAccessStatusUpdate=!1):(a.workspace.waitingForServerAccessStatusUpdate=!1,a.workspace.accessStatusUpdateAjaxError=!0),a.workspace.editAccessForm.accessPolicy=a.workspace.getAccessPolicy()},function(){a.workspace.waitingForServerAccessStatusUpdate=!1,a.workspace.accessStatusUpdateAjaxError=!0,a.workspace.editAccessForm.accessPolicy=a.workspace.getAccessPolicy()})},a.$on("$routeUpdate",function(){e()}),e()}]),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(){a.animationsChecked=!a.animationsChecked,a.animationsChecked?delete c.search().animationsDisabled:c.search().animationsDisabled=!0,c.search(c.search())},a.toggleTopMenu=function(){a.topMenuCollapsed=!a.topMenuCollapsed,a.topMenuCollapsed?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("edditingEmail"===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().edditingDisplayName?(a.editDisplayNameText=a.displayName,a.edditingDisplayName=!0):a.edditingDisplayName=!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"].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().edditingDisplayName=!0,b.search(b.search())},a.terminateEditDisplayName=function(){delete b.search().edditingDisplayName,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"].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().edditingEmail&&-1!==b.search().edditingEmail.indexOf(a.emailInstance)?(a.editEmailText=a.emailInstance,a.edditingEmail=!0):a.edditingEmail=!1}e(),a.editEmail=function(c){var d=b.search();a.removeEmailAjaxError=!1,d.edditingEmail=void 0===d.edditingEmail?c:b.search().edditingEmail+"#"+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"].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"].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("edditingEmail"===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",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"].success?document.location.pathname="schemacat/site/index.html":(a.waitingForServer=!1,a.ajaxError=!0)},function(){a.waitingForServer=!1,a.ajaxError=!0})}}]);
  • cats/SCHEMAcat/trunk/urn.org.isocat.schemacat.site/site/scripts/services.js

    r4127 r4372  
    1212SCHEMAcat.factory('Schema', ['$resource',
    1313    function($resource) {
    14         var schema = $resource('/schemacat/schemas/:schemaID', {
    15             schemaID: ''
     14        var schema = $resource('/schemacat/schemas/:schemaID/:schemaField', {
     15            schemaID: '',
     16            schemaField: ''
    1617        });
    1718        return schema;
  • cats/SCHEMAcat/trunk/urn.org.isocat.schemacat.site/site/scripts/services.min.js

    r4126 r4372  
    1 "use strict";SCHEMAcat.factory("SchemasList",["$resource",function(a){var b=a("/schemacat/users/:userID/schemas/pagedlist/page/:startPage/pagesize/:pageSize",{userID:"guest"});return b}]),SCHEMAcat.factory("Schema",["$resource",function(a){var b=a("/schemacat/schemas/:schemaID",{schemaID:""});return b}]),SCHEMAcat.factory("User",["$resource",function(a){var b=a("/schemacat/users/:userID",{userID:""});return b}]),SCHEMAcat.factory("Settings",["$resource",function(){function c(b){a=b}function d(){return a}function e(){return b}var a=!0,b={};return{getAnimationStatus:d,setAnimationStatus:c,getStore:e}}]);
     1"use strict";SCHEMAcat.factory("SchemasList",["$resource",function(a){var b=a("/schemacat/users/:userID/schemas/pagedlist/page/:startPage/pagesize/:pageSize",{userID:"guest"});return b}]),SCHEMAcat.factory("Schema",["$resource",function(a){var b=a("/schemacat/schemas/:schemaID/:schemaField",{schemaID:"",schemaField:""});return b}]),SCHEMAcat.factory("User",["$resource",function(a){var b=a("/schemacat/users/:userID",{userID:""});return b}]),SCHEMAcat.factory("Settings",["$resource",function(){function c(b){a=b}function d(){return a}function e(){return b}var a=!0,b={};return{getAnimationStatus:d,setAnimationStatus:c,getStore:e}}]);
  • cats/SCHEMAcat/trunk/urn.org.isocat.schemacat.site/site/styles/SCHEMAcat.css

    r4300 r4372  
    6161  height: auto;
    6262  max-width: 100%;
     63}
     64
     65.word-breaking-wraper{
     66    word-wrap: break-word;
     67}
     68
     69#access-actions .tooltip-inner {
     70    max-width: 350px;
    6371}
    6472
  • cats/SCHEMAcat/trunk/urn.org.isocat.schemacat.site/site/styles/SCHEMAcat.min.css

    r4300 r4372  
    1 body,html{height:100%}body{overflow-y:scroll}.centered{text-align:center}#about,#accountDetails,#contact,#schema-div,#workspace{-webkit-animation-duration:.25s;-moz-animation-duration:.25s;-o-animation-duration:.25s;animation-duration:.25s}#schema-background{min-height:350px}input.ng-dirty.ng-invalid{color:#b94a48;border-color:#e9322d;-webkit-box-shadow:0 0 6px #f8b9b7;-moz-box-shadow:0 0 6px #f8b9b7;box-shadow:0 0 6px #f8b9b7}.cursor-pointer{cursor:pointer}.cursor-default{cursor:default}.sidebar-nav-fixed{position:fixed;width:21.97%;min-width:246px}.paginator{white-space:nowrap;min-width:241px}.img-responsive-inline{display:inline-block;height:auto;max-width:100%}pre{overflow-x:auto;overflow-wrap:normal;word-wrap:normal}pre code{background-color:inherit;white-space:pre;float:left;min-width:100%}#wrap{min-height:100%;height:auto!important;height:100%;margin:0 auto -71px}#footer,#pushf,#pushh{height:71px}#footer{background-color:#f5f5f5;padding-top:20px}.schemacat-fluid-container{padding-left:15px;padding-right:15px;margin-left:auto;margin-right:auto}.schemacat-fluid-container .jumbotron{border-radius:6px}.modal{overflow-y:auto}body.modal-open{overflow:scroll}@media (max-width:767px){#footer{margin-left:-20px;margin-right:-20px;padding-left:20px;padding-right:20px}.navbar-fixed-top{position:relative;top:auto}#pushh{height:0}}@media (max-width:1009px){.sidebar-nav-fixed{position:static;width:auto}}
     1body,html{height:100%}body{overflow-y:scroll}.centered{text-align:center}#about,#accountDetails,#contact,#schema-div,#workspace{-webkit-animation-duration:.25s;-moz-animation-duration:.25s;-o-animation-duration:.25s;animation-duration:.25s}#schema-background{min-height:350px}input.ng-dirty.ng-invalid{color:#b94a48;border-color:#e9322d;-webkit-box-shadow:0 0 6px #f8b9b7;-moz-box-shadow:0 0 6px #f8b9b7;box-shadow:0 0 6px #f8b9b7}.cursor-pointer{cursor:pointer}.cursor-default{cursor:default}.sidebar-nav-fixed{position:fixed;width:21.97%;min-width:246px}.paginator{white-space:nowrap;min-width:241px}.img-responsive-inline{display:inline-block;height:auto;max-width:100%}.word-breaking-wraper{word-wrap:break-word}#access-actions .tooltip-inner{max-width:350px}pre{overflow-x:auto;overflow-wrap:normal;word-wrap:normal}pre code{background-color:inherit;white-space:pre;float:left;min-width:100%}#wrap{min-height:100%;height:auto!important;height:100%;margin:0 auto -71px}#footer,#pushf,#pushh{height:71px}#footer{background-color:#f5f5f5;padding-top:20px}.schemacat-fluid-container{padding-left:15px;padding-right:15px;margin-left:auto;margin-right:auto}.schemacat-fluid-container .jumbotron{border-radius:6px}.modal{overflow-y:auto}body.modal-open{overflow:scroll}@media (max-width:767px){#footer{margin-left:-20px;margin-right:-20px;padding-left:20px;padding-right:20px}.navbar-fixed-top{position:relative;top:auto}#pushh{height:0}}@media (max-width:1009px){.sidebar-nav-fixed{position:static;width:auto}}
Note: See TracChangeset for help on using the changeset viewer.