diff --git a/src/css/partials/_widget_share_modal.scss b/src/css/partials/_widget_share_modal.scss index 74216508..3f81d4ce 100644 --- a/src/css/partials/_widget_share_modal.scss +++ b/src/css/partials/_widget_share_modal.scss @@ -93,7 +93,7 @@ text-decoration: none; font-size: 15px; position: absolute; - left: 5px; + left: -30px; top: 30px; } .name { diff --git a/src/js/controllers/ctrl-my-widgets-collaboration.js b/src/js/controllers/ctrl-my-widgets-collaboration.js index 6d1915fb..0d3ccb22 100644 --- a/src/js/controllers/ctrl-my-widgets-collaboration.js +++ b/src/js/controllers/ctrl-my-widgets-collaboration.js @@ -132,9 +132,8 @@ app.controller('MyWidgetsCollaborationController', function ( $scope.inputs.userSearchInput = '' if ($scope.selected.widget.guest_access === false && user.is_student) { - $scope.alert.msg = - 'Students can not be given access to this widget unless Guest Mode is enabled!' - $scope.alert.title = 'Unable to share with student' + $scope.alert.msg = 'Access must be set to "Guest Mode" to collaborate with students.' + $scope.alert.title = 'Share Not Allowed' $scope.alert.fatal = false return } diff --git a/src/js/controllers/ctrl-my-widgets-selected.js b/src/js/controllers/ctrl-my-widgets-selected.js index 26daa258..0a3f2cdf 100644 --- a/src/js/controllers/ctrl-my-widgets-selected.js +++ b/src/js/controllers/ctrl-my-widgets-selected.js @@ -112,22 +112,14 @@ app.controller('MyWidgetsSelectedController', function ( $scope.show.olderScores = true } - const _canCopy = () => - [ACCESS.COPY, ACCESS.FULL, ACCESS.SHARE, ACCESS.SU].includes($scope.selected.accessLevel) - const _canDelete = () => [ACCESS.FULL, ACCESS.SU].includes($scope.selected.accessLevel) - const _canShare = () => - [ACCESS.SHARE, ACCESS.FULL, ACCESS.SU].includes($scope.selected.accessLevel) - const _canView = () => - [ACCESS.VISIBLE, ACCESS.SHARE, ACCESS.FULL, ACCESS.SU].includes($scope.selected.accessLevel) - const _showCopyDialog = () => { - if (_canCopy()) { + if ($scope.selected.can.copy) { $scope.show.copyModal = true } } const _showDelete = () => { - if (_canDelete()) { + if ($scope.selected.can.delete) { $scope.show.deleteDialog = !$scope.show.deleteDialog } } diff --git a/src/js/controllers/ctrl-my-widgets.js b/src/js/controllers/ctrl-my-widgets.js index 275f5792..2c9892d3 100644 --- a/src/js/controllers/ctrl-my-widgets.js +++ b/src/js/controllers/ctrl-my-widgets.js @@ -159,31 +159,36 @@ app.controller('MyWidgetsController', function ( // Second half of populateDisplay // This allows us to update the display before the callback of scores finishes, which speeds up UI const populateAccess = () => { - // accessLevel == ACCESS.VISIBLE is effectively read-only - if ( - ($scope.perms.user[$scope.user.id] != null - ? $scope.perms.user[$scope.user.id][0] - : undefined) != null - ) { - $scope.selected.accessLevel = Number($scope.perms.user[$scope.user.id][0]) + const sel = $scope.selected + const perms = $scope.perms + const userId = $scope.user.id + const perm = (perms.user[userId] && perms.user[userId][0]) || ACCESS.VISIBLE + sel.accessLevel = parseInt(perm, 10) + sel.can = { + view: [ACCESS.VISIBLE, ACCESS.COPY, ACCESS.SHARE, ACCESS.FULL, ACCESS.SU].includes( + sel.accessLevel + ), + copy: [ACCESS.COPY, ACCESS.SHARE, ACCESS.FULL, ACCESS.SU].includes(sel.accessLevel), + edit: [ACCESS.FULL, ACCESS.SU].includes(sel.accessLevel), + delete: [ACCESS.FULL, ACCESS.SU].includes(sel.accessLevel), + share: [ACCESS.SHARE, ACCESS.FULL, ACCESS.SU].includes(sel.accessLevel), } - $scope.selected.editable = - $scope.selected.accessLevel > ACCESS.VISIBLE && - parseInt($scope.selected.widget.widget.is_editable) === 1 + sel.editable = + $scope.selected.accessLevel > ACCESS.VISIBLE && parseInt(sel.widget.widget.is_editable) === 1 - if ($scope.selected.editable) { - $scope.selected.edit = `/widgets/${$scope.selected.widget.widget.dir}create\#${$scope.selected.widget.id}` + if (sel.editable) { + sel.edit = `/widgets/${sel.widget.widget.dir}create\#${sel.widget.id}` } else { - $scope.selected.edit = '#' + sel.edit = '#' } _countCollaborators() - $scope.selected.shareable = $scope.selected.accessLevel !== ACCESS.VISIBLE + sel.shareable = sel.accessLevel !== ACCESS.VISIBLE // old, but difficult to replace with sel.can.share :/ - populateAvailability($scope.selected.widget.open_at, $scope.selected.widget.close_at) - populateAttempts($scope.selected.widget.attempts) + populateAvailability(sel.widget.open_at, sel.widget.close_at) + populateAttempts(sel.widget.attempts) } // count up the number of other users collaborating