Skip to content

Commit

Permalink
fix(editors): slider value not shown with undefined & fix small styling
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Jan 6, 2021
1 parent b080bcb commit b85c6c5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/app/modules/angular-slickgrid/editors/dateEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class DateEditor implements Editor {
}

this._$editorInputElm = $(`<div class="flatpickr input-group"></div>`);
const closeButtonElm = $(`<span class="input-group-btn" data-clear>
const closeButtonElm = $(`<span class="input-group-btn input-group-append" data-clear>
<button class="btn btn-default icon-close" type="button"></button>
</span>`);
this._$input = $(`<input type="text" data-input data-defaultDate="${this.defaultDate}" class="${inputCssClasses.replace(/\./g, ' ')}" placeholder="${placeholder}" title="${title}" />`);
Expand Down
12 changes: 6 additions & 6 deletions src/app/modules/angular-slickgrid/editors/sliderEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ const DEFAULT_MAX_VALUE = 100;
const DEFAULT_STEP = 1;

export class SliderEditor implements Editor {
private _defaultValue = 0;
private _elementRangeInputId: string;
private _elementRangeOutputId: string;
private _$editorElm: any;
private _$input: any;
$sliderNumber: any;
defaultValue: any;
originalValue: any;

/** SlickGrid Grid object */
Expand Down Expand Up @@ -63,8 +63,8 @@ export class SliderEditor implements Editor {

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

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

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

if (this.editorParams.hideSliderNumber) {
return `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
.flatpickr.input-group {
.input-group-btn {
.btn {
border-left: 0 !important;
background-color: #eeeeee;
border: 1px solid #cccccc;
padding: $date-editor-clear-button-icon-padding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.input-group-btn:last-child > .btn, .input-group-btn:last-child > .btn-group {
z-index: 2;
margin-left: -1px;
}

.input-group-addon:not(:first-child):not(:last-child),
.input-group-btn:not(:first-child):not(:last-child),
Expand Down

0 comments on commit b85c6c5

Please sign in to comment.