-
Notifications
You must be signed in to change notification settings - Fork 625
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1336 Create a reusable component for custome field editing and refac…
…tor the case and alert custom fields sections
- Loading branch information
Showing
5 changed files
with
74 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
frontend/app/scripts/components/common/custom-field-input.component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
angular.module('theHiveComponents') | ||
.component('customFieldInput', { | ||
controller: function() { | ||
this.updateField = function(newValue) { | ||
this.onUpdate({ | ||
fieldName: ['customFields', this.field.reference, this.field.type].join('.'), | ||
value: newValue | ||
}); | ||
}; | ||
}, | ||
controllerAs: '$ctrl', | ||
templateUrl: 'views/components/common/custom-field-input.component.html', | ||
bindings: { | ||
field: '<', | ||
value: '=', | ||
onUpdate: '&', | ||
editable: '<' | ||
} | ||
}); | ||
})(); |
39 changes: 39 additions & 0 deletions
39
frontend/app/views/components/common/custom-field-input.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<dl class="dl-horizontal"> | ||
<dt class="pull-left" uib-tooltip="{{$ctrl.field.description}}">{{$ctrl.field.name}}</dt> | ||
<dd ng-if="$ctrl.editable && $ctrl.field.options.length > 0"> | ||
<updatable-select | ||
options="$ctrl.field.options" | ||
on-update="$ctrl.updateField(newValue)" | ||
value="$ctrl.value"></updatable-select> | ||
</dd> | ||
<dd ng-if="$ctrl.editable && $ctrl.field.options.length === 0" ng-switch="$ctrl.field.type"> | ||
<updatable-simple-text ng-switch-when="string" | ||
input-type="text" on-update="$ctrl.updateField(newValue)" value="$ctrl.value"></updatable-simple-text> | ||
|
||
<updatable-date ng-switch-when="date" on-update="$ctrl.updateField(newValue)" value="$ctrl.value"></updatable-date> | ||
|
||
<updatable-simple-text ng-switch-when="integer" | ||
input-type="integer" | ||
on-update="$ctrl.updateField(newValue)" | ||
value="$ctrl.value"></updatable-simple-text> | ||
|
||
<updatable-simple-text ng-switch-when="float" | ||
input-type="float" | ||
on-update="$ctrl.updateField(newValue)" | ||
value="$ctrl.value"></updatable-simple-text> | ||
|
||
<updatable-boolean ng-switch-when="boolean" | ||
input-type="number" | ||
on-update="$ctrl.updateField(newValue)" | ||
value="$ctrl.value"></updatable-boolean> | ||
|
||
<span ng-switch-default>Not Editable</span> | ||
</dd> | ||
<dd ng-if="!$ctrl.editable" ng-switch="$ctrl.field.type"> | ||
<span ng-switch-when="date">{{$ctrl.value | shortDate}}</span> | ||
<span ng-switch-default> | ||
{{$ctrl.value}} | ||
<em class="text-warning" ng-if="!$ctrl.value">Not Specified</em> | ||
</span> | ||
</dd> | ||
</dl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters