Skip to content

Commit 8e79a31

Browse files
authored
Feature/refactore proposal branch (#27)
1 parent d780112 commit 8e79a31

File tree

76 files changed

+5473
-5140
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+5473
-5140
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/collection.json

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
{
2-
"$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
3-
"schematics": {
4-
"ng-add": {
5-
"description": "Add ui schematics library",
6-
"factory": "./ng-add/index#add"
7-
},
8-
"table": {
9-
"description": "Create a component that displays data with a data-table",
10-
"factory": "./ng-generate/table/index",
11-
"schema": "./ng-generate/table/schema.json"
12-
},
13-
"table-prompter": {
14-
"description": "generate custom prompter",
15-
"factory": "./ng-generate/table-prompter/index"
16-
},
17-
"table-generation": {
18-
"description": "Executes the table generation",
19-
"factory": "./ng-generate/table/index#generateTable",
20-
"schema": "./ng-generate/table/schema.json"
21-
},
22-
"i18n": {
23-
"description": "Add i18n strategy to the application",
24-
"factory": "./ng-generate/i18n/index",
25-
"schema": "./ng-generate/i18n/schema.json"
26-
},
27-
"types": {
28-
"description": "Generate type definitions for an aspect model",
29-
"factory": "./ng-generate/types/index",
30-
"schema": "./ng-generate/types/schema.json"
31-
}
2+
"$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
3+
"schematics": {
4+
"ng-add": {
5+
"description": "Add ui schematics library",
6+
"factory": "./ng-add/index#add"
7+
},
8+
"table": {
9+
"description": "Create a component that displays data with a data-table",
10+
"factory": "./ng-generate/table/index",
11+
"schema": "./ng-generate/table/schema.json"
12+
},
13+
"table-prompter": {
14+
"description": "generate custom prompter",
15+
"factory": "./ng-generate/table-prompter/index"
16+
},
17+
"table-generation": {
18+
"description": "Executes the table generation",
19+
"factory": "./ng-generate/table/index#generate",
20+
"schema": "./ng-generate/table/schema.json"
21+
},
22+
"i18n": {
23+
"description": "Add i18n strategy to the application",
24+
"factory": "./ng-generate/i18n/index",
25+
"schema": "./ng-generate/i18n/schema.json"
26+
},
27+
"types": {
28+
"description": "Generate type definitions for an aspect model",
29+
"factory": "./ng-generate/types/index",
30+
"schema": "./ng-generate/types/schema.json"
3231
}
32+
}
3333
}

src/ng-generate/i18n/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import {chain, Rule} from '@angular-devkit/schematics';
1515
import {Schema} from './schema';
1616
import {addPackageJsonDependencies, addPackageJsonScripts} from '../../utils/package-json';
1717
import {NodeDependencyType} from '@schematics/angular/utility/dependencies';
18-
import {generateTranslationModule} from '../../utils/aspect-model';
1918
import {TemplateHelper} from '../../utils/template-helper';
2019
import {formatGeneratedFiles} from '../../utils/file';
2120
import ora from 'ora';
21+
import {generateTranslationModule} from "../table/generators/modules/translation/index";
2222

2323
/**
2424
* generates translation files for aspect model.

src/ng-generate/table-prompter/index.ts

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ function getTtlPaths(promptSubj: Subject<any>, allAnswers: Schema, subscriber: S
190190
// listener
191191
const process = inquirer.prompt(promptSubj as any).ui.process;
192192
process.subscribe(
193-
(singleAnswer: {name: string; answer: any}) => {
193+
(singleAnswer: { name: string; answer: any }) => {
194194
switch (true) {
195195
case singleAnswer.name === createOrImport.name: {
196196
if (singleAnswer.answer) {
@@ -255,7 +255,8 @@ function getTtlPaths(promptSubj: Subject<any>, allAnswers: Schema, subscriber: S
255255
err => {
256256
console.log('Error: ', err);
257257
},
258-
() => {}
258+
() => {
259+
}
259260
);
260261

261262
promptSubj.next(createOrImport);
@@ -357,7 +358,7 @@ function loadSourceProcessResult(allAnswers: any, tree: Tree, options: Schema, p
357358
.then(aspect => {
358359
resolve(
359360
!aspect.isCollectionAspect &&
360-
loader.filterElements((entry: DefaultEntity) => entry instanceof DefaultEntity).length >= 1
361+
loader.filterElements((entry: DefaultEntity) => entry instanceof DefaultEntity).length >= 1
361362
);
362363
})
363364
.catch(error => reject(error));
@@ -641,19 +642,19 @@ function getUserConfigQuestions(allAnswers: any, tree: Tree, options: Schema): Q
641642
value: 'addCustomCommandBarActions',
642643
},
643644
];
644-
if (templateHelper.getStringProperties(options).length > 0) {
645+
if (templateHelper.getStringProperties(options as Schema).length > 0) {
645646
choices.push({
646647
name: 'Search for string properties',
647648
value: 'addSearchBar',
648649
});
649650
}
650-
if (templateHelper.getDateProperties(options).length > 0) {
651+
if (templateHelper.getDateProperties(options as Schema).length > 0) {
651652
choices.push({
652653
name: 'Quick filters for properties of type date',
653654
value: 'addDateQuickFilters',
654655
});
655656
}
656-
if (templateHelper.getEnumProperties(options).length > 0) {
657+
if (templateHelper.getEnumProperties(options as Schema).length > 0) {
657658
choices.push({
658659
name: 'Quick filters for properties of type enumeration',
659660
value: 'addEnumQuickFilters',
@@ -672,25 +673,29 @@ function getUserConfigQuestions(allAnswers: any, tree: Tree, options: Schema): Q
672673
name: 'chooseLanguageForSearch',
673674
message: 'Which language should be used for the search functionality?',
674675
when: (answers: any) =>
675-
answers.addCommandBar && new TemplateHelper().isAddCommandBarFunctionSearch(answers.enabledCommandBarFunctions),
676+
answers.addCommandBar && new TemplateHelper().hasSearchBar(answers),
676677
choices: () => {
677-
loadAspect(allAnswers, tree).then(aspect => {
678-
const templateHelper = new TemplateHelper();
679-
let selectedElement: Aspect | Entity = aspect;
680-
if (allAnswers.selectedModelElementUrn && allAnswers.selectedModelElementUrn.length > 0) {
681-
selectedElement = loader.findByUrn(allAnswers.selectedModelElementUrn) as Aspect | Entity;
682-
}
678+
return new Promise<any>((resolve, reject) => {
679+
loadAspect(allAnswers, tree)
680+
.then(aspect => {
681+
const templateHelper = new TemplateHelper();
682+
let selectedElement: Aspect | Entity = aspect;
683+
if (allAnswers.selectedModelElementUrn && allAnswers.selectedModelElementUrn.length > 0) {
684+
selectedElement = loader.findByUrn(allAnswers.selectedModelElementUrn) as Aspect | Entity;
685+
}
683686

684-
const languageCodes = templateHelper.resolveAllLanguageCodes(selectedElement);
685-
const choices = [{name: 'English', value: 'en'}];
687+
const languageCodes = templateHelper.resolveAllLanguageCodes(selectedElement);
688+
const choices = [{name: 'English', value: 'en'}];
686689

687-
languageCodes.forEach(code => {
688-
if (code !== 'en') {
689-
choices.push({name: locale.getByTag(code).name, value: code});
690-
}
691-
});
690+
languageCodes.forEach(code => {
691+
if (code !== 'en') {
692+
choices.push({name: locale.getByTag(code).name, value: code});
693+
}
694+
});
692695

693-
return choices;
696+
resolve(choices);
697+
})
698+
.catch(error => reject(error));
694699
});
695700
},
696701
default: 'en',
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<div class="scrollable-chips-container" *ngIf="filterService.activeFilters.length">
2+
<button data-test="scroll-left-button" mat-mini-fab class="mat-elevation-z0"
3+
[disabled]="chipsScrollEl.disableLeftBtn" (click)="chipsScrollEl.scrollChipList('left')"
4+
*ngIf="chipsScrollEl.scrollable">
5+
<mat-icon data-test="scroll-left-icon" class="material-icons"
6+
[matTooltip]="'scroll.left' | translate">chevron_left
7+
</mat-icon>
8+
</button>
9+
<div class="chip-list-container" data-test="chip-list-container" horizontalOverflow
10+
#chipsScrollEl="horizontalOverflow" #chipList [chipsObj]="chips">
11+
<mat-chip-list data-test="chip-list" #chips>
12+
<mat-chip
13+
data-test="chip"
14+
*ngFor="let filter of filterService.activeFilters"
15+
[removable]="filter.removable"
16+
(removed)="triggerRemoveFilter(filter)"
17+
>
18+
<div data-test="chip-text" class="chip-text" matTooltip="{{ chipListValue(filter) }}">
19+
{{ chipListValue(filter) }}
20+
</div>
21+
<button *ngIf="filter.removable" matChipRemove data-test="mat-chip-remove">
22+
<mat-icon class="material-icons" data-test="remove-chip">cancel</mat-icon>
23+
</button>
24+
</mat-chip>
25+
</mat-chip-list>
26+
</div>
27+
<button data-test="scroll-right-button" mat-mini-fab class="mat-elevation-z0"
28+
[disabled]="chipsScrollEl.disableRightBtn" (click)="chipsScrollEl.scrollChipList('right')"
29+
*ngIf="chipsScrollEl.scrollable">
30+
<mat-icon data-test="scroll-right-icon" class="material-icons"
31+
[matTooltip]="'scroll.right' | translate">chevron_right
32+
</mat-icon>
33+
</button>
34+
</div>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/** <%= options.generationDisclaimerText %> **/
2+
:host ::ng-deep .mat-chip-list-wrapper {
3+
margin: 0;
4+
display: flex;
5+
flex-direction: row;
6+
flex-wrap: nowrap;
7+
align-items: center;
8+
9+
.mat-chip {
10+
flex: 0 0 auto;
11+
}
12+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/** <%= options.enerationDisclaimerText %> **/
2+
import {Component, EventEmitter, Output} from '@angular/core';
3+
import {FilterEnums, FilterType, <%= classify(name) %>FilterService} from './<%= dasherize(name) %>-filter.service';
4+
5+
@Component({
6+
selector: 'chip-list',
7+
templateUrl: './<%= dasherize(name) %>-chip-list.component.html',
8+
styleUrls: ['./<%= dasherize(name) %>-chip-list.component.scss']
9+
})
10+
export class <%= classify(name) %>ChipListComponent {
11+
@Output() removeFilter = new EventEmitter<any>();
12+
13+
constructor(public filterService: <%= classify(name) %>FilterService) {
14+
}
15+
16+
triggerRemoveFilter(filter: any): void {
17+
this.removeFilter.emit(filter);
18+
}
19+
20+
chipListValue(filter: FilterType): string {
21+
if (filter.type === FilterEnums.Search) {
22+
return `${filter.filterValue}: ${filter.label}`;
23+
}
24+
25+
if (filter.type === FilterEnums.Date) {
26+
return filter.label;
27+
}
28+
29+
return `${filter.prop}: ${filter.label}`;
30+
}
31+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
3+
*
4+
* See the AUTHORS file(s) distributed with this work for
5+
* additional information regarding authorship.
6+
*
7+
* This Source Code Form is subject to the terms of the Mozilla Public
8+
* License, v. 2.0. If a copy of the MPL was not distributed with this
9+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
10+
*
11+
* SPDX-License-Identifier: MPL-2.0
12+
*/
13+
14+
import {
15+
apply,
16+
applyTemplates,
17+
MergeStrategy,
18+
mergeWith,
19+
move,
20+
Rule,
21+
SchematicContext,
22+
Tree,
23+
url
24+
} from '@angular-devkit/schematics';
25+
import {strings} from '@angular-devkit/core';
26+
27+
export function generateChipList(options: any): Rule {
28+
return (tree: Tree, _context: SchematicContext) => {
29+
return mergeWith(
30+
apply(url('./generators/components/chip-list/files'), [
31+
applyTemplates({
32+
classify: strings.classify,
33+
dasherize: strings.dasherize,
34+
options: options,
35+
name: options.name,
36+
}),
37+
move(options.path),
38+
]),
39+
options.overwrite? MergeStrategy.Overwrite : MergeStrategy.Error
40+
);
41+
};
42+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<div class="mat-h3 selection-title" (click)="$event.stopPropagation();">{{ 'columns' | translate }}</div>
2+
3+
<mat-divider></mat-divider>
4+
<mat-selection-list cdkDropList (cdkDropListDropped)="columnDrop($event)" data-test="column-selection-list" class="selection-list">
5+
<mat-list-option cdkDrag data-test="column-list-option" *ngFor="let column of columns" [selected]="column.selected" (click)="columnClick($event, column)">
6+
<div class="list-content">
7+
<div class="list-text">
8+
<div data-test="column-option-preferred-name">{{ '<% if (options.versionedAccessPrefix) { %><%= options.versionedAccessPrefix %><% } %>' + column.name + '.preferredName' | translate }}</div>
9+
<div class="mat-small" data-test="column-option-description">{{ '<% if (options.versionedAccessPrefix) { %><%= options.versionedAccessPrefix %><% } %>' + column.name + '.description' | translate }}</div>
10+
</div>
11+
<mat-icon data-test="drag-indicator-icon" matTooltip="Draggable row" class="material-icons" style="color:rgba(0,0,0,.54);">drag_indicator</mat-icon>
12+
</div>
13+
</mat-list-option>
14+
</mat-selection-list>
15+
16+
<mat-divider></mat-divider>
17+
18+
<div data-test="column-menu-actions-container" class="menu-actions-container" (click)="stopMenuClosing($event)">
19+
<button
20+
data-test="restore-to-defaults-button"
21+
class="column-menu-restore-btn"
22+
mat-stroked-button
23+
color="accent"
24+
(click)="resetStoredColumns($event)"
25+
>
26+
<mat-icon data-test="restore-to-defaults-icon" class="material-icons">settings_backup_restore</mat-icon>
27+
<span data-test="restore-to-defaults-text">{{ 'restoreDefaults' | translate }}</span>
28+
</button>
29+
<span class="spacer"></span>
30+
<button
31+
data-test="column-menu-cancel-button"
32+
mat-stroked-button
33+
color="accent"
34+
class="column-menu-cancel-btn"
35+
(click)="closeMenu()"
36+
>
37+
<mat-icon data-test="column-menu-cancel-icon" class="material-icons">close</mat-icon>
38+
<span data-test="column-menu-cancel-text">{{ 'cancel' | translate }}</span>
39+
</button>
40+
41+
<button
42+
data-test="column-menu-apply-button"
43+
mat-raised-button
44+
color="primary"
45+
class="column-menu-apply-btn"
46+
(click)="storeColumns()"
47+
>
48+
<mat-icon data-test="column-menu-apply-icon" class="material-icons">check</mat-icon>
49+
<span data-test="column-menu-apply-text">{{ 'apply' | translate }}</span>
50+
</button>
51+
</div>

0 commit comments

Comments
 (0)