UNPKG

extpoint-yii2

Version:

JavaScript part for projects on ExtPoint Yii2 Boilerplate and yii2-core

41 lines (31 loc) 807 B
import _get from 'lodash-es/get'; export default class ViewComponent { constructor() { this.views = {}; } addFormViews(views) { this._addViews('form', views); } addListViews(views) { this._addViews('list', views); } _addViews(group, views) { this.views[group] = { ...this.views[group], ...views, }; } getFormView(name) { return this._getView('form', name); } getListView(name) { return this._getView('list', name); } _getView(group, name) { const view = _get(this.views, group + '.' + name); if (!view) { throw new Error(`Not found ${group} view '${name}'`); } return view; } }