|
@@ -5,8 +5,8 @@ import { MatButtonModule } from '@angular/material/button';
|
|
|
import { MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
|
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
|
import { MatInputModule } from '@angular/material/input';
|
|
|
-import { TranslateModule } from '@ngx-translate/core';
|
|
|
import Parse from "parse";
|
|
|
+import { ParseSchema } from '../../../schemas/func-parse';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-comp-edit-object',
|
|
@@ -14,26 +14,25 @@ import Parse from "parse";
|
|
|
imports:[
|
|
|
CommonModule,
|
|
|
FormsModule,
|
|
|
- MatFormFieldModule,
|
|
|
ReactiveFormsModule,
|
|
|
+ MatFormFieldModule,
|
|
|
MatInputModule,
|
|
|
MatButtonModule,
|
|
|
MatDialogModule,
|
|
|
- TranslateModule,
|
|
|
+ // MatFormFieldModule,
|
|
|
],
|
|
|
templateUrl: './comp-edit-object.component.html',
|
|
|
styleUrls: ['./comp-edit-object.component.scss']
|
|
|
})
|
|
|
export class CompEditObjectComponent {
|
|
|
jsonData:any = {}
|
|
|
- MinerCluster = Parse.Object.extend("MinerCluster")
|
|
|
-
|
|
|
formControlMap:any = {}
|
|
|
+ isFormShow:boolean = false;
|
|
|
constructor(
|
|
|
public dialogRef: MatDialogRef<CompEditObjectComponent>,
|
|
|
@Inject(MAT_DIALOG_DATA) public data: {
|
|
|
- cluster:Parse.Object|null|undefined,
|
|
|
- center:Parse.Object|null|undefined,
|
|
|
+ schema:ParseSchema|undefined,
|
|
|
+ object:Parse.Object|null|undefined,
|
|
|
fieldsArray:Array<any>|null,
|
|
|
title:string|null,
|
|
|
default?:any
|
|
@@ -41,19 +40,25 @@ export class CompEditObjectComponent {
|
|
|
){
|
|
|
// 设置数据校验
|
|
|
this.data?.fieldsArray?.forEach(field=>{
|
|
|
+ this.formControlMap[field?.key] = new FormControl(field?.key)
|
|
|
if(field?.require){
|
|
|
this.formControlMap[field?.key] = new FormControl(field?.key, [Validators.required]);
|
|
|
}
|
|
|
})
|
|
|
- if(this.data.cluster?.toJSON()){
|
|
|
- this.jsonData = this.data?.cluster?.toJSON();
|
|
|
+ if(this.data.object?.toJSON()){
|
|
|
+ this.jsonData = this.data?.object?.toJSON();
|
|
|
+ console.log(this.jsonData)
|
|
|
}
|
|
|
- if(!this.data?.cluster?.id){
|
|
|
- this.data.cluster = new this.MinerCluster()
|
|
|
+ if(!this.data?.object?.id){
|
|
|
+ let className:any = this.data?.object?.className || this.data.schema?.className
|
|
|
+ let SchemaContructor = Parse.Object.extend(className)
|
|
|
+ this.data.object = new SchemaContructor()
|
|
|
}
|
|
|
}
|
|
|
ngOnInit(){
|
|
|
-
|
|
|
+ setTimeout(() => {
|
|
|
+ this.isFormShow = true
|
|
|
+ }, 200);
|
|
|
}
|
|
|
/**
|
|
|
* 保存与取消
|
|
@@ -83,16 +88,16 @@ export class CompEditObjectComponent {
|
|
|
delete this.jsonData.updatedAt
|
|
|
delete this.jsonData.createdAt
|
|
|
delete this.jsonData.ACL
|
|
|
- this.data?.cluster?.set(this.jsonData);
|
|
|
+ this.data?.object?.set(this.jsonData);
|
|
|
|
|
|
// 设置默认值
|
|
|
if(this.data?.default){
|
|
|
- this.data?.cluster?.set(this.data?.default)
|
|
|
+ this.data?.object?.set(this.data?.default)
|
|
|
}
|
|
|
|
|
|
// 保存并返回
|
|
|
- this.data.cluster = await this.data?.cluster?.save();
|
|
|
- this.dialogRef.close(this.data?.cluster);
|
|
|
+ this.data.object = await this.data?.object?.save();
|
|
|
+ this.dialogRef.close(this.data?.object);
|
|
|
this.isSaving = false
|
|
|
|
|
|
}
|