77 . component ( "manageSortTagsModal" , {
88 template : `
99 <div class="modal-header">
10- <button type="button" class="close" ng-click="$ctrl.dismiss()"><span>×</span></button>
10+ <button type="button" class="close" aria-label="Close" ng-click="$ctrl.dismiss()"><span aria-hidden="true" >×</span></button>
1111 <h4 class="modal-title">Edit Tags</h4>
1212 </div>
1313 <div class="modal-body">
14- <div ui-sortable="$ctrl.sortableOptions" ng-model="$ctrl.tags">
15- <div ng-repeat="tag in $ctrl.tags track by tag.id" class="list-item selectable" style="padding: 1px 15px;border-radius: 7px;" ng-click="$ctrl.openAddOrEditTagModal(tag)" aria-label="{{item + ' (Click to edit)'}}">
16- <span class="dragHandle" ng-click="$event.stopPropagation();" style="height: 38px; width: 15px; align-items: center; justify-content: center; display: flex">
17- <i class="fal fa-bars" aria-hidden="true"></i>
18- </span>
19- <span>{{tag.name}}</span>
20- <span class="clickable" style="color: #fb7373;" ng-click="$ctrl.removeTag(tag.id);$event.stopPropagation();">
21- <i class="fad fa-trash-alt" aria-hidden="true"></i>
22- </span>
23- </div>
24- </div>
25- <div ng-show="$ctrl.tags.length < 1" class="muted" style="margin: 10px 0;">No tags created yet.</div>
26- <div style="margin: 10px 0 5px 0px;">
27- <button class="btn btn-default" ng-click="$ctrl.openAddOrEditTagModal()"><i class="far fa-plus-circle"></i> Add Tag</button>
28- </div>
14+ <firebot-list
15+ ng-model="$ctrl.tags"
16+ name="tags"
17+ id="tags"
18+ settings="$ctrl.tagListSettings"
19+ on-add-new-clicked="$ctrl.addNewTag()"
20+ on-edit-clicked="$ctrl.editTag(index)"
21+ on-delete-clicked="$ctrl.deleteTag(index)"
22+ ></firebot-list>
2923 </div>
3024 <div class="modal-footer">
31- <button type="button" class="btn btn-link " ng-click="$ctrl.dismiss()">Cancel</button>
25+ <button type="button" class="btn btn-default " ng-click="$ctrl.dismiss()">Cancel</button>
3226 <button type="button" class="btn btn-primary" ng-click="$ctrl.save()">Save</button>
3327 </div>
3428 ` ,
3832 dismiss : "&" ,
3933 modalInstance : "<"
4034 } ,
41- controller : function ( $scope , utilityService ) {
35+ controller : function ( utilityService ) {
4236 const $ctrl = this ;
4337
44- $ctrl . sortableOptions = {
45- handle : ".dragHandle" ,
46- stop : ( ) => { }
38+ $ctrl . tagListSettings = {
39+ sortable : true ,
40+ nameProperty : 'name' ,
41+ connectItems : false ,
42+ showIndex : false ,
43+ addLabel : 'Add Tag' ,
44+ noneAddedText : 'No tags added yet.'
4745 } ;
4846
4947 $ctrl . tags = [ ] ;
5048
51- $ctrl . removeTag = ( tagId ) => {
52- $ctrl . tags = $ctrl . tags . filter ( t => t . id !== tagId ) ;
53- } ;
54-
55- $ctrl . openAddOrEditTagModal = ( tag ) => {
49+ const openAddOrEditTagModal = ( tag ) => {
5650 utilityService . openGetInputModal (
5751 {
5852 model : tag ? tag . name : "" ,
8175 } ) ;
8276 } ;
8377
78+ $ctrl . addNewTag = ( ) => {
79+ openAddOrEditTagModal ( ) ;
80+ } ;
81+
82+ $ctrl . editTag = ( index ) => {
83+ openAddOrEditTagModal ( $ctrl . tags [ index ] ) ;
84+ } ;
85+
86+ $ctrl . deleteTag = ( index ) => {
87+ $ctrl . tags . splice ( index , 1 ) ;
88+ } ;
89+
8490 $ctrl . $onInit = ( ) => {
8591 if ( $ctrl . resolve . tags != null ) {
8692 $ctrl . tags = JSON . parse ( angular . toJson ( $ctrl . resolve . tags ) ) ;
94100 } ;
95101 }
96102 } ) ;
97- } ( ) ) ;
103+ } ( ) ) ;
0 commit comments