Skip to content

Commit 67214fb

Browse files
authored
Merge pull request #22 from bci-oss/feature/RBS-9993-make-material-theme-optional
Feature/rbs 9993 make material theme optional
2 parents 3247430 + e4c1b99 commit 67214fb

File tree

5 files changed

+52
-14
lines changed

5 files changed

+52
-14
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,8 @@ Example of configuration file:
585585
"customCommandBarActions": ["edit.svg"],
586586
"enableRemoteDataHandling": true,
587587
"enableVersionSupport": true,
588-
"overwrite": true
588+
"overwrite": true,
589+
"getOptionalMaterialTheme": false
589590
}
590591
```
591592
@@ -611,6 +612,29 @@ ng generate @esmf/semantic-ui-schematics:table --overwrite
611612
612613
---
613614
615+
### Add material css theme
616+
617+
If you want to add the indigo pink material theme, you may use the '--getOptionalMaterialTheme' flag
618+
619+
```bash
620+
ng generate @esmf/semantic-ui-schematics:table --getOptionalMaterialTheme
621+
```
622+
623+
if user did not set --getOptionalMaterialTheme to true but wants to add a material theme to the project,
624+
in angular.json in styles section the following code can be added:
625+
626+
```bash
627+
{
628+
"styles": [
629+
"src/styles.scss",
630+
"node_modules/@angular/material/prebuilt-themes/indigo-pink.css"
631+
]
632+
}
633+
634+
```
635+
636+
---
637+
614638
## Documentation
615639
616640
Further documentation and howto's are provided in the

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

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ function getTtlPaths(promptSubj: Subject<any>, allAnswers: Schema, subscriber: S
152152
message: 'Please enter a name for your config file. It will be automatically appended to (<config-file-name>-wizard.config.json):',
153153
validate: function (input: string) {
154154
return input.length === 0 ? 'The config file name cannot be empty. Please provide a valid name.' : true;
155-
}
155+
},
156156
};
157157

158158
const importConfigFile = {
@@ -161,7 +161,8 @@ function getTtlPaths(promptSubj: Subject<any>, allAnswers: Schema, subscriber: S
161161
excludeFilter: (nodePath: any) => !nodePath.endsWith('wizard.config.json'),
162162
excludePath: (nodePath: any) => nodePath.startsWith('node_modules'),
163163
itemType: 'file',
164-
message: 'Choose the path to an existing wizard config file which ends with "wizard.config.json". Start writing file name for suggestions:',
164+
message:
165+
'Choose the path to an existing wizard config file which ends with "wizard.config.json". Start writing file name for suggestions:',
165166
rootPath: './',
166167
suggestOnly: false,
167168
depthLimit: 5,
@@ -188,7 +189,7 @@ function getTtlPaths(promptSubj: Subject<any>, allAnswers: Schema, subscriber: S
188189
// listener
189190
const process = inquirer.prompt(promptSubj as any).ui.process;
190191
process.subscribe(
191-
(singleAnswer: { name: string; answer: any }) => {
192+
(singleAnswer: {name: string; answer: any}) => {
192193
switch (true) {
193194
case singleAnswer.name === createOrImport.name: {
194195
if (singleAnswer.answer) {
@@ -253,8 +254,7 @@ function getTtlPaths(promptSubj: Subject<any>, allAnswers: Schema, subscriber: S
253254
err => {
254255
console.log('Error: ', err);
255256
},
256-
() => {
257-
}
257+
() => {}
258258
);
259259

260260
promptSubj.next(createOrImport);
@@ -356,7 +356,7 @@ function loadSourceProcessResult(allAnswers: any, tree: Tree, options: Schema, p
356356
.then(aspect => {
357357
resolve(
358358
!aspect.isCollectionAspect &&
359-
loader.filterElements((entry: DefaultEntity) => entry instanceof DefaultEntity).length >= 1
359+
loader.filterElements((entry: DefaultEntity) => entry instanceof DefaultEntity).length >= 1
360360
);
361361
})
362362
.catch(error => reject(error));
@@ -525,6 +525,14 @@ function getUserConfigQuestions(allAnswers: any, tree: Tree, options: Schema): Q
525525
default: false,
526526
};
527527

528+
const requestOptionalMaterialTheme = {
529+
type: 'confirm',
530+
name: 'getOptionalMaterialTheme',
531+
message: 'Do you want to add the Angular Material theme? (Indigo Pink Theme)',
532+
when: () => !options.getOptionalMaterialTheme,
533+
default: false,
534+
};
535+
528536
const requestCustomRowActions = {
529537
type: 'suggest',
530538
name: 'customRowActions',
@@ -675,15 +683,14 @@ function getUserConfigQuestions(allAnswers: any, tree: Tree, options: Schema): Q
675683
const languageCodes = templateHelper.resolveAllLanguageCodes(selectedElement);
676684
const choices = [{name: 'English', value: 'en'}];
677685

678-
679686
languageCodes.forEach(code => {
680687
if (code !== 'en') {
681688
choices.push({name: locale.getByTag(code).name, value: code});
682689
}
683690
});
684691

685-
return choices
686-
})
692+
return choices;
693+
});
687694
},
688695
default: 'en',
689696
};
@@ -751,6 +758,7 @@ function getUserConfigQuestions(allAnswers: any, tree: Tree, options: Schema): Q
751758
requestEnableRemoteDataHandling,
752759
requestCustomService,
753760
requestAspectModelVersionSupport,
761+
requestOptionalMaterialTheme,
754762
requestCustomStyleImports,
755763
requestOverwriteFiles,
756764
];

src/ng-generate/table/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,10 @@ function updateConfigFiles(options: any): Rule {
611611
addStylePreprocessorOptions(angularBuildOptions);
612612

613613
const defaultMaterialtheme = 'node_modules/@angular/material/prebuilt-themes/indigo-pink.css';
614-
615-
if (!angularBuildOptions['styles'].includes(defaultMaterialtheme)) {
616-
angularBuildOptions['styles'].push(defaultMaterialtheme);
614+
if (options.getOptionalMaterialTheme) {
615+
if (!angularBuildOptions['styles'].includes(defaultMaterialtheme)) {
616+
angularBuildOptions['styles'].push(defaultMaterialtheme);
617+
}
617618
}
618619

619620
tree.overwrite('/angular.json', JSON.stringify(angularJson, null, 2));

src/ng-generate/table/schema.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@
159159
"type": "boolean",
160160
"default": false,
161161
"description": "Weather or not to install dependencies at the end of the generation process."
162+
},
163+
"getOptionalMaterialTheme": {
164+
"type": "boolean",
165+
"default": false
162166
}
163167
}
164-
}
168+
}

src/ng-generate/table/schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,6 @@ export interface Schema extends ComponentSchema, DefaultSchema {
6868
overwrite: boolean;
6969
complexProps: Array<{prop: string; propsToShow: ComplexEntityProperty[]}>;
7070
skipInstall: boolean;
71+
getOptionalMaterialTheme: boolean;
7172
skipImport: boolean;
7273
}

0 commit comments

Comments
 (0)