Skip to content

Commit

Permalink
make mongo selecttable form validate accessable
Browse files Browse the repository at this point in the history
  • Loading branch information
baisui1981 committed Oct 17, 2023
1 parent 6337bba commit a348d25
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 108 deletions.
19 changes: 8 additions & 11 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/common/navigate.bar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ import {expressionType} from "@angular/compiler/src/output/output_ast";
</li>
</ng-container>
<ng-container *ngSwitchCase="false">
<li class="index-select-block" nz-menu-item nzMatchRouter>
<nz-select name="selectedCollection"
style="width: 100%;"
Expand Down Expand Up @@ -270,6 +271,7 @@ export class NavigateBarComponent extends BasicFormComponent implements OnInit {
}

ngOnInit(): void {

const getIndeNameList = (fuzzName: string) => {
return this._http
.get(`/tjs/runtime/applist.ajax?emethod=query_app&action=app_view_action&query=${fuzzName}`)
Expand Down Expand Up @@ -298,7 +300,9 @@ export class NavigateBarComponent extends BasicFormComponent implements OnInit {

// let getUserUrl = `/runtime/applist.ajax?emethod=get_user_info&action=user_action`;
// this.httpPost(getUserUrl, '').then((r) => {
// console.log(this.tisService.containMeta);
if (this.tisService.containMeta) {

let meta: TISBaseProfile = this.tisService.tisMeta;
this.userProfile = meta.usr;
this.tisMeta = meta.tisMeta
Expand Down
107 changes: 71 additions & 36 deletions src/common/schema.edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import {TISService} from "./tis.service";
import {NzModalService} from "ng-zorro-antd/modal";
import {
DataTypeDesc,
DataTypeMeta,
DataTypeMeta, ErrorFeedback,
KEY_DOC_FIELD_SPLIT_METAS,
ReaderColMeta,
RowAssist,
TabletView
} from "./tis.plugin";
import {NzNotificationService} from "ng-zorro-antd/notification";

const KEY_COLUMN_SIZE = "columnSize";
const KEY_DECIMAL_DIGITS = "decimalDigits";
const KEY_FEEDBAKC = "Feedback";

@Component({
selector: "db-schema-editor",
Expand Down Expand Up @@ -119,7 +122,7 @@ import {NzNotificationService} from "ng-zorro-antd/notification";
</nz-form-item>
</ng-template>
</tis-col>
<tis-col *ngIf="view.elementContainKey('mongoFieldType')" title="Mongo Type">
<tis-col *ngIf="view.elementContainKey('mongoFieldType')" title="Mongo Type">
<ng-template let-u='r'>
{{ u.mongoFieldType}}
<nz-switch *ngIf="u.mongoDocType" nzSize="small" [(ngModel)]="u.openAssist"
Expand Down Expand Up @@ -147,38 +150,52 @@ import {NzNotificationService} from "ng-zorro-antd/notification";
<ng-template #jdbcTypeTemplate let-u='u'>
<!-- {{u | json}}-->
<!-- {{u.type.type}}-->
<nz-space>
<nz-select *nzSpaceItem nzShowSearch class="type-select" [disabled]="u.disable"
nzDropdownMatchSelectWidth="true" [(ngModel)]="u.type.type"
nzPlaceHolder="请选择" (ngModelChange)="typeChange(u.type)">
<nz-option [nzValue]="tp.type.type" [nzLabel]="tp.type.typeName"
*ngFor="let tp of this.typeMetas"></nz-option>
</nz-select>
<ng-container
*ngTemplateOutlet="assistType;context:{typemeta:getColTypeMeta(u.type.type),u:u};">
</ng-container>
<ng-template #assistType let-typemeta="typemeta" let-u="u">
<ng-container *ngIf="typemeta.containColSize">
<nz-input-number [disabled]="u.disable" nz-tooltip nzTooltipTitle="Column Size"
*nzSpaceItem
[(ngModel)]="u.type.columnSize"
[nzMin]="typemeta.colsSizeRange.min"
[nzMax]="typemeta.colsSizeRange.max"></nz-input-number>
</ng-container>
<ng-container *ngIf="typemeta.containDecimalRange">
<nz-input-number [disabled]="u.disable" nz-tooltip nzTooltipTitle="Decimal Digits Size"
*nzSpaceItem
[(ngModel)]="u.type.decimalDigits"
[nzMin]="typemeta.decimalRange.min"
[nzMax]="typemeta.decimalRange.max"></nz-input-number>
<!-- {{u | json}}-->
<!-- {{u.type.type}}-->
<nz-form-item>
<nz-space>
<nz-select *nzSpaceItem nzShowSearch class="type-select" [disabled]="u.disable"
nzDropdownMatchSelectWidth="true" [(ngModel)]="u.type.type"
nzPlaceHolder="请选择" (ngModelChange)="typeChange(u.type)">
<nz-option [nzValue]="tp.type.type" [nzLabel]="tp.type.typeName"
*ngFor="let tp of this.typeMetas"></nz-option>
</nz-select>
<ng-container
*ngTemplateOutlet="assistType;context:{typemeta:getColTypeMeta(u.type.type),u:u};">
</ng-container>
</ng-template>
</nz-space>
<ng-template #assistType let-typemeta="typemeta" let-u="u" let-colSizeFeedback="u.type.columnSizeFeedback" let-decimalDigitsFeedback="u.type.decimalDigitsFeedback">
<ng-container *ngIf="typemeta.containColSize">
<nz-form-control *nzSpaceItem [nzValidateStatus]="colSizeFeedback?.validateStatus"
[nzHasFeedback]="colSizeFeedback?.hasFeedback"
[nzErrorTip]="colSizeFeedback?.error">
<nz-input-number [disabled]="u.disable" nz-tooltip nzTooltipTitle="Column Size"
[(ngModel)]="u.type.columnSize"
[nzMin]="typemeta.colsSizeRange.min"
[nzMax]="typemeta.colsSizeRange.max"></nz-input-number>
</nz-form-control>
</ng-container>
<ng-container *ngIf="typemeta.containDecimalRange">
<nz-form-control *nzSpaceItem [nzValidateStatus]="decimalDigitsFeedback?.validateStatus"
[nzHasFeedback]="decimalDigitsFeedback?.hasFeedback"
[nzErrorTip]="decimalDigitsFeedback?.error">
<nz-input-number [disabled]="u.disable" nz-tooltip nzTooltipTitle="Decimal Digits Size"
[(ngModel)]="u.type.decimalDigits"
[nzMin]="typemeta.decimalRange.min"
[nzMax]="typemeta.decimalRange.max"></nz-input-number>
</nz-form-control>
</ng-container>
</ng-template>
</nz-space>
</nz-form-item>
</ng-template>
`
Expand Down Expand Up @@ -222,23 +239,41 @@ export class SchemaEditComponent extends BasicFormComponent implements AfterCont
}
// KEY_DOC_FIELD_SPLIT_METAS
let err: { name: string, };

for (let idx = 0; idx < errors.length; idx++) {
let colMeta: ReaderColMeta = this.colsMeta[idx];
if (!colMeta) {
continue;
}
err = errors[idx];
for (let key in err) {
switch (key) {
case "name":
this.colsMeta[idx].ip.error = err[key];
colMeta.ip.error = err[key];
break;
case KEY_COLUMN_SIZE:
case KEY_DECIMAL_DIGITS:
colMeta.type[key + KEY_FEEDBAKC] = new ErrorFeedback(err[key]);
break;
case KEY_DOC_FIELD_SPLIT_METAS:
let splitMetasErrors: Array<any> = err[key];
// console.log(splitMetasErrors);
let metaErr = null;
let splitMetas: Array<RowAssist> = RowAssist.getDocFieldSplitMetas(this.colsMeta[idx]);
let splitMetas: Array<RowAssist> = RowAssist.getDocFieldSplitMetas(colMeta);
let ra: RowAssist = null;
for (let idxMeta = 0; idxMeta < splitMetasErrors.length; idxMeta++) {
ra = splitMetas[idxMeta];
metaErr = splitMetasErrors[idxMeta];
for (let errKey in metaErr) {
ra.getIp(errKey).error = metaErr[errKey];
switch(errKey){
case KEY_COLUMN_SIZE:
case KEY_DECIMAL_DIGITS:
ra.type[errKey + KEY_FEEDBAKC] = new ErrorFeedback(metaErr[errKey]);
break;
default:
ra.getIp(errKey).error = metaErr[errKey];
}
// console.log([ra,idxMeta]);
}
}

Expand All @@ -263,7 +298,7 @@ export class SchemaEditComponent extends BasicFormComponent implements AfterCont
this.colsMeta = view.mcols;
this.typeMetas = view.typeMetas;
this.view = view;
// console.log([this.colsMeta ,this.typeMetas]);
// console.log([this.colsMeta ,this.typeMetas]);
}

private _typeMap: Map<number, DataTypeMeta>
Expand Down
58 changes: 35 additions & 23 deletions src/common/tis.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,42 @@ export const TYPE_PLUGIN_SELECTION = 6;
export const TYPE_PLUGIN_MULTI_SELECTION = 8;
export const KEY_DEFAULT_VALUE = 'dftVal';

export class ErrorFeedback {
_error: string | any;

constructor(error?: string) {
this._error = error;
}


public get error(): string | any {
return this._error;
}

public set error(content: string | any) {
this._error = content;
}

get hasFeedback(): boolean {
let err = this.error;
return !(!err) && typeof err === "string";
}

get validateStatus(): string {
return this.hasFeedback ? 'error' : '';
}
}

// 某一插件某一属性行
export class ItemPropVal {
export class ItemPropVal extends ErrorFeedback {
key: string;
type: number;
options: Array<ValOption>;
required: boolean;
// 如果考到通用性的化这里应该是数组类型,现在考虑到简单实现,线默认用一个单独的
descVal: DescribleVal;
advance: boolean;
_error: string | any;
// _error: string | any;
public _eprops: { string: any };
private dftVal: any;
placeholder: string;
Expand All @@ -83,15 +109,9 @@ export class ItemPropVal {

constructor(public updateModel = false) {
// console.log("create");
super();
}

public get error(): string | any {
return this._error;
}

public set error(content: string | any) {
this._error = content;
}

set eprops(vals: { String: any }) {
// @ts-ignore
Expand Down Expand Up @@ -148,14 +168,6 @@ export class ItemPropVal {
this._eprops[key] = val;
}

get hasFeedback(): boolean {
let err = this.error;
return !(!err) && typeof err === "string";
}

get validateStatus(): string {
return this.hasFeedback ? 'error' : '';
}

set primary(val: any) {
this._primaryVal = val;
Expand Down Expand Up @@ -423,7 +435,7 @@ export class SynchronizeMcolsResult {
export interface ReaderColMeta {
index: number;
name: string;
type: string;
type: string | any;
disable: boolean;
ip: ItemPropVal;
// extraProps?: { string?: any };
Expand Down Expand Up @@ -656,14 +668,14 @@ export class Item {
public wrapItemVals(): void {
let newVals = {};
let ovals: any /**map*/ = this.vals;
// console.log([this.dspt.impl, this.vals]);
// console.log([this.dspt.impl, this.vals]);
let newVal: ItemPropVal;
// console.log(this.dspt.attrs);
this.dspt.attrs.forEach((at) => {
let v = ovals[at.key];
// console.log([at.key, v, at]);
newVal = Item.wrapItemPropVal(v, at);
// console.log([at.key, newVal]);
// console.log([at.key, newVal]);
if (newVal) {
newVals[at.key] = (newVal);
}
Expand Down Expand Up @@ -929,7 +941,7 @@ export const KEY_DOC_FIELD_SPLIT_METAS = "docFieldSplitMetas";
* 该类目前只为mongo 的document 类型的field拆解而用
*/
export class RowAssist {
public _ip: Map<string, ItemPropVal>;
public _ip: Map<string, ErrorFeedback>;

public static getDocFieldSplitMetas(u: ReaderColMeta): Array<RowAssist> {
let rowAssist: Array<RowAssist> = u[KEY_DOC_FIELD_SPLIT_METAS];
Expand All @@ -944,10 +956,10 @@ export class RowAssist {
}

constructor(public name: string, public jsonPath: string, public type: DataTypeDesc) {
this._ip = new Map<string, ItemPropVal>();
this._ip = new Map<string, ErrorFeedback>();
}

public getIp(propName: string): ItemPropVal {
public getIp(propName: string): ErrorFeedback {
let ip = this._ip.get(propName);
if (!ip) {
ip = new ItemPropVal();
Expand Down
Binary file removed src/images/dingding_talk_group.jpeg
Binary file not shown.
Binary file added src/images/weixin_talk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a348d25

Please sign in to comment.