Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
fix: empty value boolean properties in @cds/angular
Browse files Browse the repository at this point in the history
Signed-off-by: stsogoo <stsogoo@vmware.com>
  • Loading branch information
Shijir committed May 14, 2021
1 parent e16ac2e commit c6fd116
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
6 changes: 6 additions & 0 deletions apps/core-angular-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,16 @@
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"postcss-cli": "7.1.0",
"protractor": "~7.0.0",
"sass": "1.32.8",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.1.2"
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
}
}
2 changes: 2 additions & 0 deletions apps/core-angular-cli/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

<cds-button status="success" (click)="show = true">Open Alert</cds-button>

<cds-tag status="success" readonly>Should not be focusable, readonly</cds-tag>

<section cds-layout="grid cols:6 gap:lg">
<cds-accordion>
<cds-accordion-panel [expanded]="panel1Expanded" (expandedChange)="expandedChange($event)">
Expand Down
2 changes: 1 addition & 1 deletion apps/core-angular-cli/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class AppComponent {
return this.form.controls.password.touched && this.form.controls.password.hasError('minlength');
}

expandedChange(event): void {
expandedChange(event: CustomEvent): void {
this.panel1Expanded = event.detail;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,25 @@
* The full license information can be found in LICENSE in the root directory of this project.
*/

import { Directive, {{#hasProps}} Input {{/hasProps}} } from '@angular/core';
import { Directive {{#hasProps}}, Input {{/hasProps}} {{#hasEvents}}, Output, EventEmitter {{/hasEvents}} } from '@angular/core';
import { BaseCdsDirective } from '../../cds-base';

@Directive({ selector: '{{tagName}}' })
export class {{directiveClassName}} extends BaseCdsDirective {
{{#props}}
get {{name}}() { return this.element['{{name}}']; }
@Input() set {{name}}(value) { this.element['{{name}}'] = value; };
@Input() set {{name}}(value: any) {
{{#isBoolean}}
if(value === "") {
this.element['{{name}}'] = true;
return;
}
{{/isBoolean}}
this.element['{{name}}'] = value;
};
{{/props}}

{{#events}}
@Output() {{name}}: EventEmitter<CustomEvent> = new EventEmitter();
{{/events}}
}
4 changes: 3 additions & 1 deletion scripts/core-ng-module-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ function createDirectives(componentDirectories) {
const templateData = {
tagName: tag.name,
directiveClassName: getDirectiveClassName(tag.name, '', 'Directive'),
props: tag.properties,
props: tag.properties && tag.properties.map(p => ({ ...p, isBoolean: p.type === 'boolean' })),
events: tag.events,
hasProps: !!tag.properties,
hasEvents: !!tag.events,
};

const directory = getDiretoryName(tag.path);
Expand Down

0 comments on commit c6fd116

Please sign in to comment.