Skip to content

Commit

Permalink
Date picker fixes (#636)
Browse files Browse the repository at this point in the history
* Fixed date range limits 9ci/rcm-ui#52

* date-range manual enter 9ci/rcm-ui#51

* date-range manual enter
  • Loading branch information
alexeyzvegintcev authored Nov 25, 2021
1 parent bbd48ab commit d37a579
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/ng/controls/ag-datepicker/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,24 @@ class Controller extends AgBaseControl {
const isoDate = displayDateToIso(this.value)
this.ngModelCtrl.$setViewValue(isoDate)
// if dialog is open then update the change there too
if (this.datepicker.active) this.datepicker.update()
//if (this.datepicker.active) this.datepicker.update()
}

onBlur() {
const isoDate = displayDateToIso(this.value)
this.ngModelCtrl.$setViewValue(isoDate)
this.datepicker.update()
}

$onDestroy() {
this.datepicker.destroy()
}

onEnter(event) {
const isoDate = displayDateToIso(this.value)
this.ngModelCtrl.$setViewValue(isoDate)
this.datepicker.update()
}
}

const template = `
Expand All @@ -70,6 +78,7 @@ const template = `
placeholder="{{$ctrl.placeholder}}"
name="{{$ctrl.name}}"
id="{{$ctrl.elementId}}"
ng-keydown="$event.keyCode === 13 && $ctrl.onEnter($event)"
ng-model="$ctrl.value"
ng-model-options='{ debounce: 500 }'
ng-change="$ctrl.onChange()"
Expand Down
3 changes: 1 addition & 2 deletions src/ng/controls/ag-daterange/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class Controller extends AgBaseControl {
super.onInit()
const fromFld = this.opts.fromField.name
const toFld = this.opts.toField.name

this.ngModelCtrl.$render = () => {
let vmv = this.ngModelCtrl.$viewValue
vmv = _.isEmpty(vmv) ? { [fromFld]: '', [toFld]: '' } : vmv
Expand All @@ -41,7 +40,7 @@ class Controller extends AgBaseControl {
const fromFld = this.opts.fromField.name
const toFld = this.opts.toField.name

const fromToObj = { [fromFld]: this.valueFrom, [toFld]: this.valueTo }
const fromToObj = { ...(this.valueFrom && {[fromFld]: this.valueFrom}), ...(this.valueTo && { [toFld]: this.valueTo}) }
// Log.debug('onChange fromToObj', fromToObj)
this.ngModelCtrl.$setViewValue(fromToObj)
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/growl/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Notyf } from 'notyf'
// import 'notyf/notyf.min.css'
import themeColors from 'angle-grinder/src/themeColors'
import themeColors from '../../themeColors'

// const themeColors = {
// success: 'hsla(85, 77%, 35%, .97)',
Expand Down

0 comments on commit d37a579

Please sign in to comment.