-import {Component, Input} from '@angular/core';
-import {Router} from '@angular/router';
+import {Component, Input, ViewChild} from '@angular/core';
+import {Router, Routes} from '@angular/router';
import {GridDataSource} from '@eg/share/grid/grid';
import {Pager} from '@eg/share/util/pager';
import {PcrudService} from '@eg/core/pcrud.service';
+import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
+import {StringComponent} from '@eg/share/string/string.component';
+import {ToastService} from '@eg/share/toast/toast.service';
+import {GridComponent} from '@eg/share/grid/grid.component';
+import {AdminPageComponent} from '@eg/staff/share/admin-page/admin-page.component';
+import {OrgService} from '@eg/core/org.service';
+import {PermService} from '@eg/core/perm.service';
+import {AuthService} from '@eg/core/auth.service';
+import {IdlService, IdlObject} from '@eg/core/idl.service';
@Component({
templateUrl: './edit-floating-group.component.html'
})
- export class EditFloatingGroupComponent {
+ export class EditFloatingGroupComponent extends AdminPageComponent {
@Input() idlClass = 'cfgm';
@Input() sortField: string;
@Input() dataSource: GridDataSource;
@Input() dialogSize: 'sm' | 'lg' = 'lg';
-
+ @ViewChild('grid') grid: GridComponent;
+ @ViewChild('editDialog') editDialog: FmRecordEditorComponent;
+ @ViewChild('createString') createString: StringComponent;
+
+
// This is the ID of the floating group being edited currently
currentId: string;
+ translatableFields: string[];
+ createNew: () => void;
constructor(
- private pcrud: PcrudService,
- private router: Router
+ pcrud: PcrudService,
+ toast: ToastService,
+ idl: IdlService,
+ org: OrgService,
+ auth: AuthService,
+ perm: PermService,
+ private router: Router,
) {
+ super( idl, org, auth, pcrud, perm, toast )
+
}
ngOnInit() {
- let url = this.router.routerState.snapshot.url;
- let slash = url.lastIndexOf('/');
- this.currentId = url.substring(slash+1);
+ // super.ngOnInit();
+ let currentUrl = this.router.routerState.snapshot.url;
+ let slash = currentUrl.lastIndexOf('/');
+ this.currentId = currentUrl.substring(slash+1);
this.dataSource = new GridDataSource();
this.dataSource.getRows = (pager: Pager, sort: any[]) => {
const searchOps = {
};
return this.pcrud.search(this.idlClass, {floating_group: this.currentId}, searchOps);
};
+
+ this.createNew = () => {
+ // super.createNew();
+ console.log("create new")
+ this.editDialog.mode = 'create';
+ // this.editDialog.open({size: this.dialogSize}).then(
+ // ok => {
+ // this.createString.current()
+ // .then(str => this.toast.success(str));
+ // this.grid.reload();
+ // },
+ // err => {}
+ // );
+ };
+
}
}
\ No newline at end of file