Skip to content

Commit

Permalink
#1669 Support clearable option in all updatable fields and use it i…
Browse files Browse the repository at this point in the history
…n custom field panels
  • Loading branch information
nadouani committed Nov 19, 2020
1 parent 0fd7464 commit e9f1e5b
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 15 deletions.
3 changes: 2 additions & 1 deletion frontend/app/scripts/directives/updatableBoolean.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
'active': '=?',
'placeholder': '@',
'trueText': '@?',
'falseText': '@?'
'falseText': '@?',
'clearable': '<?'
}
};
});
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/scripts/directives/updatableDataDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
'value': '=?',
'onUpdate': '&',
'active': '=?',
'placeholder': '@'
'placeholder': '@',
'clearable': '<?'

}
};
Expand Down
9 changes: 8 additions & 1 deletion frontend/app/scripts/directives/updatableDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
'restrict': 'E',
'link': function(scope, element, attrs, ctrl, transclude) {
UtilsSrv.updatableLink(scope, element, attrs, ctrl, transclude);

scope.clear = function() {
scope.value = null;
scope.humanDate = null;
};

$(element).find('.input-datetime').datetimepicker({
format: 'dd-mm-yyyy hh:ii',
weekStart: 1,
Expand Down Expand Up @@ -53,7 +59,8 @@
'scope': {
'value': '=?',
'onUpdate': '&',
'active': '=?'
'active': '=?',
'clearable': '<?'
}
};
});
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/scripts/directives/updatableSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
'value': '=?',
'onUpdate': '&',
'active': '=?',
'placeholder': '@'
'placeholder': '@',
'clearable': '<?'
}
};
});
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/scripts/directives/updatableSimpleText.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
'value': '=?',
'onUpdate': '&',
'active': '=?',
'placeholder': '@'
'placeholder': '@',
'clearable': '<?'
}
};
});
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/scripts/directives/updatableTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
'value': '=?',
'onUpdate': '&',
'active': '=?',
'source': '='
'source': '=',
'clearable': '<?'
}
};
});
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/scripts/directives/updatableText.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
'scope': {
'value': '=?',
'onUpdate': '&',
'active': '=?'
'active': '=?',
'clearable': '<?'
}
};
});
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/scripts/directives/updatableUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
query: '=',
queryParams: '=',
onUpdate: '&',
active: '=?'
active: '=?',
clearable: '<?'
}
};
});
Expand Down
3 changes: 3 additions & 0 deletions frontend/app/scripts/services/common/UtilsSrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@
scope.value = scope.oldValue;
scope.updatable.updating = false;
};
scope.clear = function() {
scope.value = null;
};
},

extractQueryParam: function(paramName, queryString) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@
<updatable-select
options="$ctrl.field.options"
on-update="$ctrl.updateField(newValue)"
value="$ctrl.value"></updatable-select>
value="$ctrl.value" clearable="true"></updatable-select>
</dd>
<dd ng-if="$ctrl.editable && $ctrl.field.options.length === 0" ng-switch="$ctrl.field.type">
<div class="custom-field-input-wrapper">
<updatable-simple-text ng-switch-when="string"
input-type="text" on-update="$ctrl.updateField(newValue)" value="$ctrl.value"></updatable-simple-text>
input-type="text" on-update="$ctrl.updateField(newValue)" value="$ctrl.value" clearable="true"></updatable-simple-text>

<updatable-date ng-switch-when="date" on-update="$ctrl.updateField(newValue)" value="$ctrl.value"></updatable-date>
<updatable-date ng-switch-when="date" on-update="$ctrl.updateField(newValue)" value="$ctrl.value" clearable="true"></updatable-date>

<updatable-simple-text ng-switch-when="integer"
input-type="integer"
on-update="$ctrl.updateField(newValue)"
value="$ctrl.value"></updatable-simple-text>
value="$ctrl.value" clearable="true"></updatable-simple-text>

<updatable-simple-text ng-switch-when="float"
input-type="float"
on-update="$ctrl.updateField(newValue)"
value="$ctrl.value"></updatable-simple-text>
value="$ctrl.value" clearable="true"></updatable-simple-text>

<updatable-boolean ng-switch-when="boolean"
input-type="number"
on-update="$ctrl.updateField(newValue)"
value="$ctrl.value"></updatable-boolean>
value="$ctrl.value" clearable="true"></updatable-boolean>

<span ng-switch-default>Not Editable</span>
</div>
Expand Down
3 changes: 3 additions & 0 deletions frontend/app/views/directives/updatable-boolean.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<button class="btn btn-sm btn-default" type="button" ng-click="cancel()">
<i class="text-danger glyphicon glyphicon-remove"></i>
</button>
<button class="btn btn-sm btn-default" type="button" ng-click="clear()" ng-if="clearable === true">
<i class="text-danger glyphicon glyphicon-erase"></i>
</button>
</span>
</div>
</form>
Expand Down
3 changes: 3 additions & 0 deletions frontend/app/views/directives/updatable-date.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<button class="btn btn-sm btn-default" type="button" ng-click="cancel()">
<i class="text-danger glyphicon glyphicon-remove"></i>
</button>
<button class="btn btn-sm btn-default" type="button" ng-click="clear()" ng-if="clearable === true">
<i class="text-danger glyphicon glyphicon-erase"></i>
</button>
</span>
</div>
</form>
Expand Down
3 changes: 3 additions & 0 deletions frontend/app/views/directives/updatable-select.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<button class="btn btn-sm btn-default" type="button" ng-click="cancel()">
<i class="text-danger glyphicon glyphicon-remove"></i>
</button>
<button class="btn btn-sm btn-default" type="button" ng-click="clear()" ng-if="clearable === true">
<i class="text-danger glyphicon glyphicon-erase"></i>
</button>
</span>
</div>
</form>
Expand Down
3 changes: 3 additions & 0 deletions frontend/app/views/directives/updatable-simple-text.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<button class="btn btn-sm btn-default" type="button" ng-click="cancel()">
<i class="text-danger glyphicon glyphicon-remove"></i>
</button>
<button class="btn btn-sm btn-default" type="button" ng-click="clear()" ng-if="clearable === true">
<i class="text-danger glyphicon glyphicon-erase"></i>
</button>
</span>
</div>
</form>
Expand Down
3 changes: 3 additions & 0 deletions frontend/app/views/directives/updatable-tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
<button type="button" class="btn btn-sm btn-default" ng-click='cancel()'>
<i class="text-danger glyphicon glyphicon-remove"></i>
</button>
<button class="btn btn-sm btn-default" type="button" ng-click="clear()" ng-if="clearable === true">
<i class="text-danger glyphicon glyphicon-erase"></i>
</button>
</div>
</span>
</div>
3 changes: 3 additions & 0 deletions frontend/app/views/directives/updatable-text.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<button type="button" class="btn btn-sm btn-default" ng-click='cancel()'>
<i class="text-danger glyphicon glyphicon-remove"></i>
</button>
<button class="btn btn-sm btn-default" type="button" ng-click="clear()" ng-if="clearable === true">
<i class="text-danger glyphicon glyphicon-erase"></i>
</button>
</div>
<a class="pull-right" href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank">
<i class="fa fa-question-circle"></i> Markdown Reference</a>
Expand Down
5 changes: 4 additions & 1 deletion frontend/app/views/directives/updatable-user.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<small class="updatable-input-icon">
<i class="glyphicon glyphicon-pencil"></i>
</small>
</small>
</span>
<span ng-init="updatable.dropdownOpen=false" ng-show="updatable.updating">
<div class="btn-group" uib-dropdown is-open="updatable.dropdownOpen">
Expand All @@ -15,6 +15,9 @@
<button class="btn btn-default btn-sm" ng-click='updatable.updating = false' type="button">
<i class="text-danger glyphicon glyphicon-remove"></i>
</button>
<button class="btn btn-sm btn-default" type="button" ng-click="clear()" ng-if="clearable === true">
<i class="text-danger glyphicon glyphicon-erase"></i>
</button>
<ul class="dropdown-menu scroll-dropdown" uib-dropdown-menu>
<li ng-repeat="user in userList">
<a ng-click="update(user.login)">{{user.organisation}}/{{user.name}}</a>
Expand Down

0 comments on commit e9f1e5b

Please sign in to comment.