Skip to content

Commit

Permalink
feat(abc:se): add hideLabel property (#1402)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Dec 29, 2021
1 parent d18aa43 commit 3ec8d06
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 8 deletions.
10 changes: 8 additions & 2 deletions packages/abc/se/demo/complex.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Use `col` to build complex irregular layouts.
```ts
import { Component } from '@angular/core';

import { STColumn } from '@delon/abc/st';

@Component({
selector: 'app-demo',
template: `
Expand Down Expand Up @@ -67,11 +69,14 @@ import { Component } from '@angular/core';
<se label="Long Long Long Long Long Long Label" col="1">
<textarea [(ngModel)]="i.comment" name="comment" nz-input rows="2" placeholder="write any thing"></textarea>
</se>
<se hideLabel col="1">
<st [columns]="columns" size="small"></st>
</se>
<se col="1">
<button nz-button nzType="primary" [disabled]="f.invalid">Save</button>
</se>
</form>
`,
`
})
export class DemoComponent {
i = {
Expand All @@ -83,7 +88,8 @@ export class DemoComponent {
phoneNumberPrefix: '+86',
phoneNumber: '',
agree: true,
comment: '',
comment: ''
};
columns: STColumn[] = [{ title: 'id' }];
}
```
1 change: 1 addition & 0 deletions packages/abc/se/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Also, automatically processed all Angular built-in validation, such as `required
| `[col]` | specify the maximum number of columns to display, the final columns number is determined by col setting combined with [Responsive Rules](/theme/responsive) (Inherited from `se-container`) | `'1','2','3','4','5','6'` | - |
| `[label]` | Label | `string, TemplateRef<void>` | - |
| `[labelWidth]` | label text of width, unit is `px` (Inherited from `se-container`) | `number` | - |
| `[hideLabel]` | Whether to hide the current label | `boolean` | `false` |
| `[optional]` | Label optional information | `string, TemplateRef<void>` | - |
| `[optionalHelp]` | Label optional help | `string, TemplateRef<void>` | - |
| `[optionalHelpColor]` | The background color of label optional help | `string` | - |
Expand Down
1 change: 1 addition & 0 deletions packages/abc/se/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ module: import { SEModule } from '@delon/abc/se';
| `[col]` | 指定表单元素最多分几列展示,最终一行几列由 col 配置结合[响应式规则](/theme/responsive)决定(继承于 `se-container`| `'1','2','3','4','5','6'` | - |
| `[label]` | 标签文本 | `string, TemplateRef<void>` | - |
| `[labelWidth]` | 标签文本宽度,单位:`px`(继承于 `se-container`| `number` | - |
| `[hideLabel]` | 是否隐藏当前 `label` | `boolean` | `false` |
| `[optional]` | 标签可选信息 | `string, TemplateRef<void>` | - |
| `[optionalHelp]` | 标签可选帮助 | `string, TemplateRef<void>` | - |
| `[optionalHelpColor]` | 标签可选帮助背景颜色 | `string` | - |
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/se/se.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="ant-form-item-label" [class.se__nolabel]="!label" [style.width.px]="_labelWidth">
<div class="ant-form-item-label" [class.se__nolabel]="hideLabel || !label" [style.width.px]="_labelWidth">
<label
*ngIf="label"
[attr.for]="_id"
Expand Down
3 changes: 3 additions & 0 deletions packages/abc/se/se.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ let nextUniqueId = 0;
host: {
'[style.padding-left.px]': 'paddingValue',
'[style.padding-right.px]': 'paddingValue',
'[class.se__hide-label]': 'hideLabel',
'[class.ant-form-item-has-error]': 'invalid',
'[class.ant-form-item-with-help]': 'showErr'
},
Expand All @@ -53,6 +54,7 @@ export class SEComponent implements OnChanges, AfterContentInit, AfterViewInit,
static ngAcceptInputType_line: BooleanInput;
static ngAcceptInputType_labelWidth: NumberInput;
static ngAcceptInputType_noColon: BooleanInput;
static ngAcceptInputType_hideLabel: BooleanInput;

private el: HTMLElement;
private unsubscribe$ = new Subject<void>();
Expand Down Expand Up @@ -87,6 +89,7 @@ export class SEComponent implements OnChanges, AfterContentInit, AfterViewInit,
@Input() @InputBoolean(null) line: boolean;
@Input() @InputNumber(null) labelWidth: number;
@Input() @InputBoolean(null) noColon: boolean;
@Input() @InputBoolean() hideLabel = false;

@Input()
set id(value: string) {
Expand Down
9 changes: 8 additions & 1 deletion packages/abc/se/se.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,16 @@ describe('abc: edit', () => {
context.parent_noColon = true;
context.noColon = undefined;
context.label = 'aa';
debugger;
fixture.detectChanges();
expect(page.getEls('.se__no-colon').length).toBe(1);
});
});
it('#hideLabel', () => {
context.hideLabel = true;
fixture.detectChanges();
expect(page.getEls('.se__hide-label').length).toBe(1);
expect(page.getEls('.se__nolabel').length).toBe(1);
});
});
describe('#item', () => {
describe('#col', () => {
Expand Down Expand Up @@ -557,6 +562,7 @@ describe('abc: edit', () => {
[line]="line"
[labelWidth]="labelWidth"
[noColon]="noColon"
[hideLabel]="hideLabel"
>
<input type="text" [(ngModel)]="val" name="val" required [disabled]="disabled" />
</se>
Expand Down Expand Up @@ -593,6 +599,7 @@ class TestComponent {
controlClass = '';
labelWidth: number | null = null;
noColon?: boolean | null = undefined;
hideLabel: boolean = false;

val = '';
showModel = true;
Expand Down
9 changes: 5 additions & 4 deletions scripts/azure/github-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@ async function withGithub(url, json, method) {
}

(async function run() {
const comments = await withGithub(`https://api.github.com/repos/${REPO}/issues/${PR}/comments`);
const commentUrl = `https://api.github.com/repos/${REPO}/issues/${PR}/comments`;
console.log(`commentUrl`, commentUrl);
const comments = await withGithub(commentUrl);
console.log(`comments data`, comments);

// Find my comment
const updateComment = comments.find(({ body }) => body.includes(REPLACE_MARK));
// eslint-disable-next-line no-console
console.log('Origin comment:', updateComment);

// Update
let res;
if (!updateComment) {
res = await withGithub(`https://api.github.com/repos/${REPO}/issues/${PR}/comments`, {
res = await withGithub(commentUrl, {
body: wrappedComment,
});
} else {
Expand All @@ -52,6 +54,5 @@ async function withGithub(url, json, method) {
);
}

// eslint-disable-next-line no-console
console.log(res);
})();

0 comments on commit 3ec8d06

Please sign in to comment.