UNPKG

@netgrif/components-core

Version:

Netgrif Application engine frontend core Angular library

66 lines 2.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ViewClassInfo = void 0; const import_to_add_1 = require("./import-to-add"); const angular_cli_devkit_core_strings_1 = require("./angular-cli-devkit-core-strings"); const schematics_1 = require("@angular-devkit/schematics"); // TODO 28.5.2020 find a better way of handling common files between lib and schematics class ViewClassInfo extends import_to_add_1.ImportToAdd { constructor(path, viewType, customComponentName) { super('', ''); if (!customComponentName) { this.prefix = ViewClassInfo.convertPathToClassNamePrefix(path); const classSuffix = ViewClassInfo.resolveClassSuffixForView(viewType); this.nameWithoutComponent = `${(0, angular_cli_devkit_core_strings_1.classify)(this.prefix)}${classSuffix}`; this.fileImportPath = `./views/${path}/${(0, angular_cli_devkit_core_strings_1.dasherize)(this.nameWithoutComponent)}.component`; } else { this.prefix = ''; this.nameWithoutComponent = (0, angular_cli_devkit_core_strings_1.classify)(customComponentName); this.fileImportPath = `./views/${path}/${(0, angular_cli_devkit_core_strings_1.dasherize)(customComponentName)}.component`; } this.className = `${this.nameWithoutComponent}Component`; } static convertPathToClassNamePrefix(path) { const regexDash = /-/g; return path.replace(regexDash, '_').replace(/\//g, '-').toLocaleLowerCase(); } static resolveClassSuffixForView(view) { switch (view) { case 'login': return 'Login'; case 'tabView': return 'TabView'; case 'taskView': return 'TaskView'; case 'caseView': return 'CaseView'; case 'emptyView': return 'EmptyView'; case 'sidenavView': return 'SidenavView'; case 'doubleDrawerView': return 'DoubleDrawerView'; case 'toolbarView': return 'ToolbarView'; case 'sidenavAndToolbarView': return 'SidenavAndToolbarView'; case 'dashboard': return 'Dashboard'; case 'groupView': return 'GroupView'; case 'treeCaseView': return 'TreeCaseView'; case 'workflowView': return 'WorkflowView'; case 'roleAssignmentView': return 'RoleAssignmentView'; case 'ldapRoleAssignmentView': return 'LdapRoleAssignmentView'; default: throw new schematics_1.SchematicsException(`Unknown view type '${view}'`); } } } exports.ViewClassInfo = ViewClassInfo; //# sourceMappingURL=view-class-info.js.map