UNPKG

@pnp/spfx-controls-react

Version:

Reusable React controls for SharePoint Framework solutions

57 lines 2.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TermLabelAction = void 0; var tslib_1 = require("tslib"); var _1 = require("."); var sp_lodash_subset_1 = require("@microsoft/sp-lodash-subset"); /** * TermAction is responsible to obtain different labels for the term. */ var TermLabelAction = /** @class */ (function () { function TermLabelAction(title, iconName) { if (iconName === void 0) { iconName = "LocaleLanguage"; } var _this = this; this.title = title; this.iconName = iconName; this.id = "TermLabelActionId"; this.applyToTerm = function (currentTerm) { var termIndex = (0, sp_lodash_subset_1.findIndex)(_this._processedTerms, function (term) { return term.Id === currentTerm.Id; }); if (termIndex >= 0) { return false; } return true; }; this.actionCallback = function (spTermService, currentTerm) { return tslib_1.__awaiter(_this, void 0, void 0, function () { var updateAction, _a, termLabel, error_1; return tslib_1.__generator(this, function (_b) { switch (_b.label) { case 0: _b.trys.push([0, 2, , 3]); updateAction = null; _a = this; return [4 /*yield*/, spTermService.getTermLabels(currentTerm.Id)]; case 1: _a._labels = _b.sent(); if (this._labels) { termLabel = this._labels.join(" ; "); updateAction = { updateActionType: _1.UpdateType.updateTermLabel, value: termLabel }; return [2 /*return*/, updateAction]; } return [2 /*return*/, null]; case 2: error_1 = _b.sent(); console.log(error_1); return [2 /*return*/, null]; case 3: return [2 /*return*/]; } }); }); }; this._processedTerms = []; } return TermLabelAction; }()); exports.TermLabelAction = TermLabelAction; //# sourceMappingURL=TermActions.js.map