UNPKG

@totvs-agro/core-mobile

Version:

Core Mobile Totvs Agro (Front-End) para utilização dos estilos do T-Faces

119 lines 7.46 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { Component, Input } from '@angular/core'; import { Variable } from '../../model/variable/variable'; import { ComponentVariable } from '../component-variable'; import { TotvsNotificationProvider } from '../../providers/notification/totvs-notification-provider'; import { TotvsTranslateProvider } from '../../providers/translate/totvs-translate-provider'; var HTML_TEMPLATE = "\n<span class=\"var-title\">{{variable.description}}</span>\n<span class=\"var-optional\" *ngIf=\"variable.optional\">({{'COMMON.OPTIONAL' | tTranslate}})</span>\n<ion-item no-lines no-padding>\n <ion-range [(ngModel)]=\"variableValue.value\" min=\"{{variable.minValue}}\" (ionChange)=\"onChangeCallback()\" max=\"{{variable.maxValue}}\">\n <ion-label range-left class=\"range-label-left\">{{variable.minValue}}</ion-label>\n <ion-label range-right class=\"range-label-right\">{{variable.maxValue}}</ion-label>\n </ion-range>\n</ion-item>\n<div class=\"var-value-label\">\n <button style=\"float: left;\" ion-button icon-only (click)=\"onMinusButtonClick()\">\n <thf-icon name=\"minus-circle\"></thf-icon>\n </button>\n \n <span class=\"{{getLegendClass()}}\" (click)=\"onEditClick()\">\n <span style=\"padding-left: 8px;\">{{variableValue.asString}}</span>\n <span *ngIf=\"variable.suffix && variableValue.value != undefined\" class=\"var-suffix\">{{variable.suffix}}</span>\n <thf-icon name=\"edit\" class=\"var-edit-icon\"></thf-icon>\n </span>\n \n <button style=\"float: right;\" ion-button icon-only (click)=\"onPlusButtonClick()\">\n <thf-icon name=\"plus-circle\"></thf-icon>\n </button>\n</div>\n"; var CSS_STYLE = "\n.range-label-left {\n font-weight: bold;\n font-size: 14px;\n padding-right: 8px;\n }\n\n .range-label-right {\n font-weight: bold;\n font-size: 14px;\n padding-left: 8px;\n }\n\n .range {\n padding: 0;\n }\n\n .range-bar {\n height: 4px !important;\n top: 20px !important;\n border-radius: 4px;\n background-color: #eee !important;\n }\n\n .range-bar-active {\n height: 4px !important;\n background-color: #0c9abe !important;\n }\n \n button {\n font-size: 24px !important;\n min-height: 26px !important;\n min-width: 26px;\n height: 26px !important;\n width: 26px;\n \n padding: 0 !important;\n padding-left: 4px !important;\n background-color: transparent !important;\n color: #ccc !important;\n }\n"; var VariableSpinnerComponent = /** @class */ (function (_super) { __extends(VariableSpinnerComponent, _super); function VariableSpinnerComponent(_notificationProvider, _totvsTranslate) { var _this = _super.call(this) || this; _this._notificationProvider = _notificationProvider; _this._totvsTranslate = _totvsTranslate; _this.variableValue = { asBoolean: false, asString: "0", value: 0 }; return _this; } VariableSpinnerComponent.prototype.ngOnInit = function () { if (this.variable.defaultValue != null) this.setValue(this.variable.defaultValue); this.onChangeCallback(); }; VariableSpinnerComponent.prototype.onEditClick = function () { var _this = this; this._notificationProvider.presentPrompt(this.variable.description, [{ name: 'value', type: 'number', value: this.variableValue.value }], [{ text: this._totvsTranslate.instant('COMMON.CANCEL'), role: 'cancel', handler: function (data) { console.log('Cancel clicked'); } }, { text: this._totvsTranslate.instant('COMMON.CONFIRM'), handler: function (data) { if (data.value) _this.setValue(data.value); _this.onChangeCallback(); } }]); }; VariableSpinnerComponent.prototype.onMinusButtonClick = function () { this.variableValue.value = +this.variableValue.value - 1; this.setValue(this.variableValue); this.onChangeCallback(); }; VariableSpinnerComponent.prototype.onPlusButtonClick = function () { this.variableValue.value = +this.variableValue.value + 1; this.setValue(this.variableValue); this.onChangeCallback(); }; VariableSpinnerComponent.prototype.getValue = function () { return this.variableValue; }; VariableSpinnerComponent.prototype.setValue = function (variableValue) { variableValue.value = +variableValue.value; if (isNaN(variableValue.value)) return; this.variableValue = { asBoolean: (variableValue.value ? true : false), asString: this.variable.decimals ? variableValue.value.toFixed(this.variable.decimals) : String(variableValue.value), value: variableValue.value }; }; VariableSpinnerComponent.prototype.getVariable = function () { return this.variable; }; VariableSpinnerComponent.prototype.onChangeCallback = function () { this.setValue(this.variableValue); this.callback(this); }; __decorate([ Input('variable'), __metadata("design:type", Variable) ], VariableSpinnerComponent.prototype, "variable", void 0); __decorate([ Input('callbackOnChange'), __metadata("design:type", Function) ], VariableSpinnerComponent.prototype, "callback", void 0); VariableSpinnerComponent = __decorate([ Component({ selector: 'variable-spinner', template: HTML_TEMPLATE, styles: [CSS_STYLE] }), __metadata("design:paramtypes", [TotvsNotificationProvider, TotvsTranslateProvider]) ], VariableSpinnerComponent); return VariableSpinnerComponent; }(ComponentVariable)); export { VariableSpinnerComponent }; //# sourceMappingURL=variable-spinner.js.map