Skip to content

Commit

Permalink
#1508 Add blank text to updatable-user component and use it in tasks …
Browse files Browse the repository at this point in the history
…section
  • Loading branch information
nadouani committed Apr 9, 2021
1 parent 7670269 commit 58d5c47
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 133 deletions.
27 changes: 14 additions & 13 deletions frontend/app/scripts/directives/updatableUser.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
(function() {
(function () {
'use strict';
angular.module('theHiveDirectives')
.directive('updatableUser', function(UserSrv, QuerySrv, UtilsSrv, AuthenticationSrv, NotificationSrv) {
.directive('updatableUser', function (UserSrv, QuerySrv, UtilsSrv, AuthenticationSrv, NotificationSrv) {
return {
restrict: 'E',
link: function(scope, element, attrs, ctrl, transclude) {
link: function (scope, element, attrs, ctrl, transclude) {
var cached = false;

UtilsSrv.updatableLink(scope, element, attrs, ctrl, transclude);

scope.setValue = function(value) {
scope.setValue = function (value) {
scope.value = value;
};
scope.getUserInfo = UserSrv.getCache;

scope.$watch('updatable.updating', function(value) {
scope.$watch('updatable.updating', function (value) {

if(value === true && !cached) {
if (value === true && !cached) {
var assignableUsers = [];

if(_.isFunction(scope.query)) {
if (_.isFunction(scope.query)) {
assignableUsers = scope.query.apply(this, scope.queryParams);
} else {
assignableUsers = scope.query;
Expand All @@ -32,12 +32,12 @@
},
sort: ['+name']
})
.then(function(users) {
scope.userList = users;
})
.catch(function(err) {
NotificationSrv.error('Fetching users', err.data, err.status);
});
.then(function (users) {
scope.userList = users;
})
.catch(function (err) {
NotificationSrv.error('Fetching users', err.data, err.status);
});

cached = true;
}
Expand All @@ -47,6 +47,7 @@
scope: {
value: '=?',
query: '=',
blankText: '@',
queryParams: '=',
onUpdate: '&',
active: '=?',
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/views/directives/updatable-user.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div class="updatable-input updatable-input-user">
<span class="updatable-input-value-wrapper" ng-hide="updatable.updating" ng-click="edit()">
<user-info class="updatable-value" value="value" field="name"></user-info>
<span ng-if="!!!value" class="updatable-value text-warning"><em>{{blankText || 'Not Specified'}}</em></span>
<user-info ng-if="!!value" class="updatable-value" value="value" field="name"></user-info>

<small class="updatable-input-icon">
<i class="glyphicon glyphicon-pencil"></i>
Expand Down
Loading

0 comments on commit 58d5c47

Please sign in to comment.