UNPKG

@totvs-agro/mobile-components

Version:

Componentes Mobile Totvs (Front-End) para utilização dos estilos do T-Faces e Ionic v3

127 lines 8.51 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = (this && this.__generator) || function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; import { Component, Input } from '@angular/core'; //import { Image } from '../../model/image'; //import { RepositoryProvider } from '../../providers/repository/repository'; //import { DataStore } from '../../util/data-store'; var HTML_TEMPLATE = "\n<ion-checkbox class=\"checkbox\" *ngIf=\"showCheckBox\" [(ngModel)]=\"checked\" (click)=\"onCheck()\"></ion-checkbox>\n<ion-item no-lines no-padding [ngClass]=\"{'ion-item-checkbox': showCheckBox\t}\">\n\t<ion-thumbnail item-start (click)=\"onClick()\">\n\t\t<img width=\"72px\" height=\"72px\" src=\"{{imageSrc}}\">\n\t</ion-thumbnail>\n\t<div (click)=\"onClick()\" [ngClass]=\"{'label-container-badge': culture, 'label-container': !culture\t}\">\n\t\t<h2>\n\t\t\t<div class=\"card-title-text\">{{commonName}}</div>\n\t\t</h2>\n\t\t<div *ngIf=\"culture\" class=\"card-title-badge\">\n\t\t\t<ion-badge class=\"card-badge\" [ngStyle]=\"{'background-color': cultureColor}\">{{culture.description}}</ion-badge>\n\t\t</div>\n\t\t<p>{{scientificName}}</p>\n\t</div>\n\t<button *ngIf=\"!infoIcons && !hideIcons\" ion-button clear item-end>\n\t\t<ion-icon name=\"ios-arrow-forward\"></ion-icon>\n\t</button>\n\t<!--<span *ngIf=\"!hideIcons\">-->\n\t<button class=\"button-icon-container-small\" *ngFor=\"let infoIcon of infoIcons\" ion-button clear item-end (click)=\"itemInfo(_item)\" [ngClass]=\"{'no-display': hideIcons}\">\n\t\t<!--Caso o item tenha algum valor espec\u00EDfico o mesmo ficar\u00E1 azul-->\n\t\t<thf-icon *ngIf=\"(infoIcon.icon != 'info' && infoIcon.hasValue)\" class=\"button-icon-small blue\" name=\"{{infoIcon.icon}}\"></thf-icon>\n\t\t<!--Padr\u00E3o com itens que n\u00E3o possuem valor-->\n\t\t<thf-icon *ngIf=\"(infoIcon.icon != 'info' && !infoIcon.hasValue)\" class=\"button-icon-small grey\" name=\"{{infoIcon.icon}}\"></thf-icon>\n\t\t<!--Icone de informa\u00E7\u00E3o-->\n\t\t<thf-icon *ngIf=\"(infoIcon.icon == 'info')\" class=\"button-icon-small grey info\" name=\"exclamation\"></thf-icon>\n\t</button>\n\t<!--</span>-->\n</ion-item>\n<hr>\n"; var ListItemComponent = /** @class */ (function () { function ListItemComponent() { //private _repositoryProvider: RepositoryProvider) { this.hideIcons = false; this.imageSrc = ""; this.showCheckBox = true; this.infoIcons = undefined; } ListItemComponent.prototype.ngOnInit = function () { return __awaiter(this, void 0, void 0, function () { var mainPhoto, result; return __generator(this, function (_a) { switch (_a.label) { case 0: if (this._item.commonNames && this._item.commonNames.length) { this.commonName = this._item.commonNames.filter(function (commonName) { return commonName.main; })[0].description; } else { this.commonName = this._item.scientificName; } this.scientificName = this._item.scientificName; mainPhoto = this._item.photos.filter(function (element) { return element.main; }); this.imageId = (mainPhoto && mainPhoto.length) ? mainPhoto[0]._id : null; this.showCheckBox = this._item.showCheckBox; this.infoIcons = this._item.infoIcons; this.checked = this._item.checked; this.culture = this._item.culture; this.cultureColor = this._item.cultureColor; if (!this.imageId) return [3 /*break*/, 2]; this.imageSrc = './assets/images/loading.gif'; return [4 /*yield*/, this.eventProcessImage(this.imageId)]; case 1: result = _a.sent(); if (result && result.encoding) { this.imageSrc = 'data:image/jpeg;base64,' + result.encoding; } else { this.imageSrc = './assets/images/noimg.png'; } return [3 /*break*/, 3]; case 2: this.imageSrc = './assets/images/noimg.png'; _a.label = 3; case 3: return [2 /*return*/]; } }); }); }; ListItemComponent.prototype.onClick = function () { if (this.showCheckBox) { this.checked = !this.checked; this.onCheck(); } else if (this.callBackOneItemSelected) { this.callBackOneItemSelected(this._item); } }; ListItemComponent.prototype.onCheck = function () { this.callbackItemCheck(this._item, this.checked); }; ListItemComponent.prototype.itemInfo = function (item) { if (this.callbackItemInfo) this.callbackItemInfo(item); else this.onClick(); }; ListItemComponent.decorators = [ { type: Component, args: [{ selector: 'list-item', template: HTML_TEMPLATE },] }, ]; /** @nocollapse */ ListItemComponent.ctorParameters = function () { return []; }; ListItemComponent.propDecorators = { "callbackItemInfo": [{ type: Input, args: ['callbackItemInfo',] },], "callbackItemCheck": [{ type: Input, args: ['callbackItemCheck',] },], "callBackOneItemSelected": [{ type: Input, args: ['callBackOneItemSelected',] },], "eventProcessImage": [{ type: Input, args: ['eventProcessImage',] },], "_item": [{ type: Input, args: ['item',] },], "hideIcons": [{ type: Input, args: ['hideIcons',] },], }; return ListItemComponent; }()); export { ListItemComponent }; //# sourceMappingURL=list-item.js.map