Skip to content

Commit

Permalink
[WIP] Add a button to clear default value
Browse files Browse the repository at this point in the history
  • Loading branch information
romanblanco committed May 28, 2019
1 parent 9e3f9dc commit 86e500b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/dialog-editor/components/abstractModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class AbstractModal {
categories: '=?',
addEntry: '=?',
removeEntry: '=?',
clearDefaultValue: '=?',
currentCategoryEntries: '=?',
setupCategoryOptions: '=?',
updateDialogFieldResponders: '=?',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
pf-datepicker
date="vm.modalData.default_value">
</div>
<button class="btn btn-default" ng-click="vm.clearDefaultValue()" translate>Clear</button>
</div>
<div pf-form-group pf-label="{{'Read only'|translate}}">
<input bs-switch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<div >
<uib-timepicker ng-model="vm.modalData.default_value"></uib-timepicker>
</div>
<button class="btn btn-default" ng-click="vm.clearDefaultValue()" translate>Clear</button>
</div>
<div pf-form-group pf-label="{{'Read only'|translate}}">
<input bs-switch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default class ModalFieldTemplate {
categories: '=?',
addEntry: '=?',
removeEntry: '=?',
clearDefaultValue: '=?',
currentCategoryEntries: '=?',
setupCategoryOptions: '=?',
resolveCategories: '=?',
Expand Down
2 changes: 2 additions & 0 deletions src/dialog-editor/components/modal-field/field.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ <h4 class="modal-title" id="myModalLabel" translate>Edit Field Details</h4>
template="date-control.html"
show-fully-qualified-name="vm.showFullyQualifiedName"
tree-options="vm.treeOptions"
clear-default-value="vm.clearDefaultValue"
modal-tab-is-set="vm.modalTabIsSet"
modal-tab="vm.modalTab"
modal-data="vm.modalData">
Expand All @@ -87,6 +88,7 @@ <h4 class="modal-title" id="myModalLabel" translate>Edit Field Details</h4>
template="date-time-control.html"
show-fully-qualified-name="vm.showFullyQualifiedName"
tree-options="vm.treeOptions"
clear-default-value="vm.clearDefaultValue"
modal-tab-is-set="vm.modalTabIsSet"
modal-tab="vm.modalTab"
modal-data="vm.modalData">
Expand Down
13 changes: 13 additions & 0 deletions src/dialog-editor/components/modal/modalComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,18 @@ class ModalController {
this.modalData.values.push(['', '']);
}

/**
* Removes default value by setting `default_value` as
* `null`
* @memberof ModalFieldController
* @function clearDefaultValue
*/
public clearDefaultValue() {
console.log(this.modalData.default_value);
// FIXME: https://stackoverflow.com/questions/12729122/angularjs-prevent-error-digest-already-in-progress-when-calling-scope-apply
this.modalData.default_value = null;
}

/**
* Remove entry for radio button / dropdown select
* @memberof ModalFieldController
Expand Down Expand Up @@ -312,6 +324,7 @@ class ModalController {
categories="modalCtrl.parent.categories"
add-entry="modalCtrl.parent.addEntry"
remove-entry="modalCtrl.parent.removeEntry"
clear-default-value="modalCtrl.parent.clearDefaultValue"
current-category-entries="modalCtrl.parent.currentCategoryEntries"
resolve-categories="modalCtrl.parent.resolveCategories"
modal-tab-is-set="modalCtrl.parent.modalTabIsSet"
Expand Down

0 comments on commit 86e500b

Please sign in to comment.