Skip to content

Commit b85c6c5

Browse files
committed
fix(editors): slider value not shown with undefined & fix small styling
1 parent b080bcb commit b85c6c5

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

src/app/modules/angular-slickgrid/editors/dateEditor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export class DateEditor implements Editor {
137137
}
138138

139139
this._$editorInputElm = $(`<div class="flatpickr input-group"></div>`);
140-
const closeButtonElm = $(`<span class="input-group-btn" data-clear>
140+
const closeButtonElm = $(`<span class="input-group-btn input-group-append" data-clear>
141141
<button class="btn btn-default icon-close" type="button"></button>
142142
</span>`);
143143
this._$input = $(`<input type="text" data-input data-defaultDate="${this.defaultDate}" class="${inputCssClasses.replace(/\./g, ' ')}" placeholder="${placeholder}" title="${title}" />`);

src/app/modules/angular-slickgrid/editors/sliderEditor.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ const DEFAULT_MAX_VALUE = 100;
1010
const DEFAULT_STEP = 1;
1111

1212
export class SliderEditor implements Editor {
13+
private _defaultValue = 0;
1314
private _elementRangeInputId: string;
1415
private _elementRangeOutputId: string;
1516
private _$editorElm: any;
1617
private _$input: any;
1718
$sliderNumber: any;
18-
defaultValue: any;
1919
originalValue: any;
2020

2121
/** SlickGrid Grid object */
@@ -63,8 +63,8 @@ export class SliderEditor implements Editor {
6363

6464
// define the input & slider number IDs
6565
const itemId = this.args && this.args.item && this.args.item.id;
66-
this._elementRangeInputId = `rangeInput_${this.columnDef.field}_${itemId}`;
67-
this._elementRangeOutputId = `rangeOutput_${this.columnDef.field}_${itemId}`;
66+
this._elementRangeInputId = `rangeInput_${this.columnDef.id}_${itemId}`;
67+
this._elementRangeOutputId = `rangeOutput_${this.columnDef.id}_${itemId}`;
6868

6969
// create HTML string template
7070
const editorTemplate = this.buildTemplateHtmlString();
@@ -143,10 +143,10 @@ export class SliderEditor implements Editor {
143143
if (item && fieldName !== undefined) {
144144
// is the field a complex object, "address.streetNumber"
145145
const isComplexObject = fieldName && fieldName.indexOf('.') > 0;
146-
let value = (isComplexObject) ? getDescendantProperty(item, fieldName) : item[fieldName];
146+
let value = (isComplexObject) ? getDescendantProperty(item, fieldName) : (item.hasOwnProperty(fieldName) ? item[fieldName] : this._defaultValue);
147147

148148
if (value === '' || value === null || value === undefined) {
149-
value = this.defaultValue; // load default value when item doesn't have any value
149+
value = this._defaultValue; // load default value when item doesn't have any value
150150
}
151151
this.originalValue = +value;
152152
this._$input.val(value);
@@ -198,7 +198,7 @@ export class SliderEditor implements Editor {
198198
const maxValue = this.columnEditor.hasOwnProperty('maxValue') ? this.columnEditor.maxValue : DEFAULT_MAX_VALUE;
199199
const defaultValue = this.editorParams.hasOwnProperty('sliderStartValue') ? this.editorParams.sliderStartValue : minValue;
200200
const step = this.columnEditor.hasOwnProperty('valueStep') ? this.columnEditor.valueStep : DEFAULT_STEP;
201-
this.defaultValue = defaultValue;
201+
this._defaultValue = defaultValue;
202202

203203
if (this.editorParams.hideSliderNumber) {
204204
return `

src/app/modules/angular-slickgrid/styles/slick-editors.scss

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
.flatpickr.input-group {
4646
.input-group-btn {
4747
.btn {
48-
border-left: 0 !important;
4948
background-color: #eeeeee;
5049
border: 1px solid #cccccc;
5150
padding: $date-editor-clear-button-icon-padding;

src/app/modules/angular-slickgrid/styles/slick-without-bootstrap-min-styling.scss

+4
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@
113113
border-top-right-radius: 0;
114114
border-bottom-right-radius: 0;
115115
}
116+
.input-group-btn:last-child > .btn, .input-group-btn:last-child > .btn-group {
117+
z-index: 2;
118+
margin-left: -1px;
119+
}
116120

117121
.input-group-addon:not(:first-child):not(:last-child),
118122
.input-group-btn:not(:first-child):not(:last-child),

0 commit comments

Comments
 (0)