-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f54a60
commit f4037e9
Showing
9 changed files
with
174 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
module.exports = async (waw) => { | ||
if (!fs.existsSync(waw.base)) { | ||
fs.mkdirSync(waw.base, { recursive: true }); | ||
} | ||
|
||
waw.base = path.join(waw.base, waw.name + "-selector"); | ||
|
||
let html = fs.readFileSync(waw.template + "/component.html", "utf8"); | ||
html = html.split("CNAME").join(waw.Name); | ||
html = html.split("NAME").join(waw.name); | ||
fs.writeFileSync(waw.base + ".component.html", html, "utf8"); | ||
|
||
let scss = fs.readFileSync(waw.template + "/component.scss", "utf8"); | ||
scss = scss.split("CNAME").join(waw.Name); | ||
scss = scss.split("NAME").join(waw.name); | ||
fs.writeFileSync(waw.base + ".component.scss", scss, "utf8"); | ||
|
||
let ts = fs.readFileSync(waw.template + "/component.ts", "utf8"); | ||
ts = ts.split("FILENAME").join(waw.fileName); | ||
ts = ts.split("CNAME").join(waw.Name); | ||
ts = ts.split("NAME").join(waw.name); | ||
fs.writeFileSync(waw.base + ".component.ts", ts, "utf8"); | ||
|
||
waw.add_code({ | ||
file: process.cwd() + "/src/app/core/core.module.ts", | ||
search: "/* selectors */", | ||
replace: `/* selectors */\n\t${waw.Name}SelectorComponent,`, | ||
}); | ||
|
||
waw.add_code({ | ||
file: process.cwd() + "/src/app/core/core.module.ts", | ||
search: "/* imports */", | ||
replace: `/* imports */\nimport { ${waw.Name}SelectorComponent } from './selectors/${waw.name}/${waw.name}-selector.component';`, | ||
}); | ||
|
||
console.log("Selector has been created"); | ||
|
||
process.exit(1); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<wselect | ||
(modelChange)="onChange.emit($event)" | ||
[items]="items" | ||
[select]="value" | ||
></wselect> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { | ||
Component, | ||
EventEmitter, | ||
Input, | ||
OnChanges, | ||
Output, | ||
SimpleChanges | ||
} from '@angular/core'; | ||
import { CNAMEService, CNAME } from 'src/app/core/services/NAME.service'; | ||
|
||
@Component({ | ||
selector: 'NAME-selector', | ||
templateUrl: './NAME-selector.component.html', | ||
styleUrls: ['./NAME-selector.component.scss'] | ||
}) | ||
export class CNAMESelectorComponent implements OnChanges { | ||
@Input() value: string; | ||
|
||
@Output() onChange = new EventEmitter(); | ||
|
||
get items(): CNAME[] { | ||
return this._NAMEService.NAMEs; | ||
} | ||
|
||
constructor(private _NAMEService: CNAMEService) {} | ||
|
||
ngOnChanges(changes: SimpleChanges): void { | ||
if (changes['value'] && !changes['value'].firstChange) { | ||
this.value = changes['value'].currentValue; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
module.exports = async (waw) => { | ||
if (!fs.existsSync(waw.base)) { | ||
fs.mkdirSync(waw.base, { recursive: true }); | ||
} | ||
|
||
waw.base = path.join(waw.base, waw.name + "-selector"); | ||
|
||
let html = fs.readFileSync(waw.template + "/component.html", "utf8"); | ||
html = html.split("CNAME").join(waw.Name); | ||
html = html.split("NAME").join(waw.name); | ||
fs.writeFileSync(waw.base + ".component.html", html, "utf8"); | ||
|
||
let scss = fs.readFileSync(waw.template + "/component.scss", "utf8"); | ||
scss = scss.split("CNAME").join(waw.Name); | ||
scss = scss.split("NAME").join(waw.name); | ||
fs.writeFileSync(waw.base + ".component.scss", scss, "utf8"); | ||
|
||
let ts = fs.readFileSync(waw.template + "/component.ts", "utf8"); | ||
ts = ts.split("FILENAME").join(waw.fileName); | ||
ts = ts.split("CNAME").join(waw.Name); | ||
ts = ts.split("NAME").join(waw.name); | ||
fs.writeFileSync(waw.base + ".component.ts", ts, "utf8"); | ||
|
||
waw.add_code({ | ||
file: process.cwd() + "/src/app/core/core.module.ts", | ||
search: "/* selectors */", | ||
replace: `/* selectors */\n\t${waw.Name}SelectorComponent,`, | ||
}); | ||
|
||
waw.add_code({ | ||
file: process.cwd() + "/src/app/core/core.module.ts", | ||
search: "/* imports */", | ||
replace: `/* imports */\nimport { ${waw.Name}SelectorComponent } from './selectors/${waw.name}/${waw.name}-selector.component';`, | ||
}); | ||
|
||
console.log("Selector has been created"); | ||
|
||
process.exit(1); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<wselect | ||
(modelChange)="onChange.emit($event)" | ||
[items]="items" | ||
[select]="value" | ||
></wselect> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { | ||
Component, | ||
EventEmitter, | ||
Input, | ||
OnChanges, | ||
Output, | ||
SimpleChanges | ||
} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'NAME-selector', | ||
templateUrl: './NAME-selector.component.html', | ||
styleUrls: ['./NAME-selector.component.scss'] | ||
}) | ||
export class CNAMESelectorComponent implements OnChanges { | ||
@Input() items = ['Yes', 'No']; // put proper items here | ||
|
||
@Input() value: string; | ||
|
||
@Output() onChange = new EventEmitter(); | ||
|
||
ngOnChanges(changes: SimpleChanges): void { | ||
if (changes['value'] && !changes['value'].firstChange) { | ||
this.value = changes['value'].currentValue; | ||
} | ||
} | ||
} |