// mode: 'create' for creating a new record,
// 'update' for editing an existing record
// 'view' for viewing an existing record without editing
- @Input() mode: 'create' | 'update' | 'view' = 'create';
+ mode: 'create' | 'update' | 'view' = 'create';
+ @Input() editMode(mode: 'create' | 'update' | 'view') {
+ this.mode = mode;
+ }
// Record ID to view/update. Value is dynamic. Records are not
// fetched until .open() is called.
+++ /dev/null
-
-<div class="eg-grid-row eg-grid-body-row"
- [ngClass]="{'eg-grid-row-selected': selector[idx]}"
- *ngFor="let row of dataSource.getPageOfRows(pager); let idx = index">
-
- <div class="eg-grid-cell eg-grid-checkbox-cell eg-grid-cell-skinny">
- <input type='checkbox' [(ngModel)]="selector[idx]">
- </div>
- <div class="eg-grid-cell eg-grid-header-cell eg-grid-number-cell eg-grid-cell-skinny">
- {{pager.rowNumber(idx)}}
- </div>
- <div class="eg-grid-cell eg-grid-body-cell" [ngStyle]="{flex:col.flex}"
- *ngFor="let col of columnSet.displayColumns()">
- {{getDisplayValue(row, col)}}
- </div>
-
-<div>
-
+++ /dev/null
-import {Component, Input, OnInit, Host, TemplateRef} from '@angular/core';
-import {EgGridService, EgGridColumn, EgGridColumnSet} from './grid.service';
-import {EgGridDataSource} from './grid-data-source';
-import {Pager} from '@eg/share/util/pager';
-
-@Component({
- selector: 'eg-grid-body',
- templateUrl: 'grid-body.component.html'
-})
-
-export class EgGridBodyComponent implements OnInit {
-
- @Input() pager: Pager;
- @Input() dataSource: EgGridDataSource;
- @Input() columnSet: EgGridColumnSet;
- @Input() selector: {[idx:number] : boolean};
-
- constructor(private gridSvc: EgGridService) { }
-
- ngOnInit() {
-
- // fetch the first page of data
- this.dataSource.requestPage(this.pager);
- }
-
- getDisplayValue(row: any, col: EgGridColumn): string {
- return this.gridSvc.getRowColumnValue(row, col);
- }
-
-}
-
@Input() flex: number;
@Input() hidden: boolean = false;
@Input() cellTemplate: TemplateRef<any>;
+ @Input() pkey: boolean;
// get a reference to our container grid.
constructor(
col.flex = this.flex || 2;
col.hidden = this.hidden;
col.cellTemplate = this.cellTemplate;
+ col.isPkey = this.pkey;
this.grid.columnSet.add(col);
}
}
<input type='checkbox'> <!-- add click handlers ; shared selector mod -->
</div>
<div class="eg-grid-cell eg-grid-header-cell eg-grid-number-cell eg-grid-cell-skinny">
- #
+ <span i18n="number|Row Number Header">#</span>
</div>
-
<div *ngFor="let col of columnSet.displayColumns()"
class="eg-grid-cell eg-grid-header-cell" [ngStyle]="{flex:col.flex}">
{{col.label}}
<div class="eg-grid">
- <eg-grid-toolbar [dataSource]="dataSource" [pager]="pager">
- </eg-grid-toolbar>
+ <eg-grid-toolbar [dataSource]="dataSource" [pager]="pager"></eg-grid-toolbar>
<eg-grid-header [columnSet]="columnSet"></eg-grid-header>
- <eg-grid-body
- [columnSet]="columnSet"
- [dataSource]="dataSource"
- [pager]="pager"
- [selector]="selector">
- </eg-grid-body>
+
+ <div class="eg-grid-row eg-grid-body-row"
+ (dblclick)="onRowDblClick(row)"
+ [ngClass]="{'eg-grid-row-selected': selector[idx]}"
+ *ngFor="let row of dataSource.getPageOfRows(pager); let idx = index">
+
+ <div class="eg-grid-cell eg-grid-checkbox-cell eg-grid-cell-skinny">
+ <input type='checkbox' [(ngModel)]="selector[idx]">
+ </div>
+ <div class="eg-grid-cell eg-grid-header-cell eg-grid-number-cell eg-grid-cell-skinny">
+ {{pager.rowNumber(idx)}}
+ </div>
+ <div class="eg-grid-cell eg-grid-body-cell" [ngStyle]="{flex:col.flex}"
+ *ngFor="let col of columnSet.displayColumns()">
+ {{getDisplayValue(row, col)}}
+ </div>
+ <div>
</div>
-import {Component, Input, OnInit, ViewEncapsulation} from '@angular/core';
+import {Component, Input, OnInit, EventEmitter, ViewEncapsulation} from '@angular/core';
import {EgGridDataSource} from './grid-data-source';
import {EgIdlService} from '@eg/core/idl.service';
import {EgOrgService} from '@eg/core/org.service';
import {Pager} from '@eg/share/util/pager';
-import {EgGridService, EgGridColumnSet} from '@eg/share/grid/grid.service';
+import {EgGridService, EgGridColumn, EgGridColumnSet}
+ from '@eg/share/grid/grid.service';
@Component({
selector: 'eg-grid',
pager: Pager;
columnSet: EgGridColumnSet;
selector: {[idx:number] : boolean};
+ onRowDblClick$: EventEmitter<any>;
constructor(private gridSvc: EgGridService) {
this.pager = new Pager();
- this.pager.limit = 10; // TODO
this.selector = {};
+ this.pager.limit = 10; // TODO
+ this.onRowDblClick$ = new EventEmitter<any>();
}
ngOnInit() {
this.columnSet = this.gridSvc.initializeColumnSet(this.idlClass);
+ this.dataSource.requestPage(this.pager);
}
+
+ reload() {
+ this.dataSource.data = [];
+ this.pager.offset = 0;
+ this.dataSource.requestPage(this.pager);
+ }
+
+ getDisplayValue(row: any, col: EgGridColumn): string {
+ return this.gridSvc.getRowColumnValue(row, col);
+ }
+
+ onRowDblClick(row: any) {
+ this.onRowDblClick$.emit(row);
+ }
+
}
) {
}
+ getRowPkey(row: any, columnSet: EgGridColumnSet): any {
+ let col = columnSet.pkeyColumn;
+ if (!col) throw new Error('grid pkey column required');
+ return this.getRowColumnValue(row, col);
+ }
+
getRowColumnValue(row: any, col: EgGridColumn): string {
if (row[col.name] === undefined || row[col.name] === null)
return '';
getRowColumnIdlValue(row: any, col: EgGridColumn): string {
let val = row[col.name]();
if (val === undefined || val === null) return '';
+
+ if (col.idlFieldDef.datatype == 'org_unit') {
+ let o = this.org.get(val);
+ if (o) return o.shortname();
+ }
+
return val+'';
}
col.name = field.name;
col.label = field.label || field.name;
col.idlFieldDef = field;
+ if (field.name == this.idl.classes[idlClass].pkey)
+ col.isPkey = true;
columnSet.add(col);
});
}
idlClass: string;
idlFieldDef: any;
cellTemplate: TemplateRef<any>;
+ isPkey: boolean;
}
export class EgGridColumnSet {
columns: EgGridColumn[];
+ pkeyColumn: EgGridColumn;
constructor() {
this.columns = [];
// avoid dupes
if (this.columns.filter(c => c.name == col.name).length) return;
+ if (col.isPkey) this.pkeyColumn = col;
+
this.columns.push(col);
}
const routes: Routes = [{
path: '',
- children : [{
- path: 'workstation',
- loadChildren: '@eg/staff/admin/workstation/routing.module#EgAdminWsRoutingModule'
+ children : [
+ { path: 'workstation',
+ loadChildren: '@eg/staff/admin/workstation/routing.module#EgAdminWsRoutingModule'
+ }, {
+ path: 'server',
+ loadChildren: '@eg/staff/admin/server/routing.module#EgAdminServerRoutingModule'
}]
}];
--- /dev/null
+<eg-staff-banner bannerText="Billing Type Configuration" i18n-bannerText>
+</eg-staff-banner>
+
+<eg-grid #btGrid idlClass="cbt" [dataSource]="dataSource">
+</eg-grid>
+
+<fm-record-editor #btEditDialog idlClass="cbt">
+</fm-record-editor>
+
+
--- /dev/null
+import {Component, OnInit, TemplateRef, ViewChild} from '@angular/core';
+import {EgGridDataSource} from '@eg/share/grid/grid-data-source';
+import {EgGridComponent} from '@eg/share/grid/grid.component';
+import {EgToastService} from '@eg/share/toast/toast.service';
+import {Pager} from '@eg/share/util/pager';
+import {EgPcrudService} from '@eg/core/pcrud.service';
+import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
+
+@Component({
+ templateUrl: './billing_type.component.html'
+})
+
+export class BillingTypeComponent implements OnInit {
+
+ dataSource: EgGridDataSource;
+ @ViewChild('btGrid') btGrid: EgGridComponent;
+ @ViewChild('btEditDialog') btEditDialog: FmRecordEditorComponent;
+
+ constructor(
+ private pcrud: EgPcrudService,
+ private toast: EgToastService
+ ) {
+ this.dataSource = new EgGridDataSource();
+ }
+
+ ngOnInit() {
+
+ this.dataSource.getRows = (pager: Pager) => {
+ return this.pcrud.retrieveAll('cbt', {
+ offset: pager.offset,
+ limit: pager.limit,
+ order_by: {cbt: 'name'}
+ });
+ }
+
+ this.btGrid.onRowDblClick$.subscribe(
+ bt => {
+ this.btEditDialog.mode = 'update';
+ this.btEditDialog.recId = bt.id();
+ this.btEditDialog.open().then(
+ ok => {
+ // TODO: i18n
+ this.toast.success('Billing Type Update Succeeded'),
+ this.btGrid.reload()
+ },
+ err => {
+ this.toast.warning('Billing Type Update Canceled')
+ }
+ );
+ }
+ );
+ }
+}
+
+
--- /dev/null
+import {NgModule} from '@angular/core';
+import {EgStaffCommonModule} from '@eg/staff/common.module';
+import {EgAdminServerConfigRoutingModule} from './routing.module';
+import {EgGridModule} from '@eg/share/grid/grid.module';
+import {BillingTypeComponent} from './billing_type.component';
+
+@NgModule({
+ declarations: [
+ BillingTypeComponent
+ ],
+ imports: [
+ EgStaffCommonModule,
+ EgAdminServerConfigRoutingModule,
+ EgGridModule
+ ],
+ providers: [
+ ]
+})
+
+export class EgAdminServerConfigModule {
+}
+
+
--- /dev/null
+import {NgModule} from '@angular/core';
+import {RouterModule, Routes} from '@angular/router';
+import {BillingTypeComponent} from './billing_type.component';
+
+const routes: Routes = [{
+ path: 'billing_type',
+ component: BillingTypeComponent
+}];
+
+@NgModule({
+ imports: [RouterModule.forChild(routes)],
+ exports: [RouterModule]
+})
+
+export class EgAdminServerConfigRoutingModule {}
--- /dev/null
+import {NgModule} from '@angular/core';
+import {RouterModule, Routes} from '@angular/router';
+
+const routes: Routes = [{
+ path: 'config',
+ loadChildren: '@eg/staff/admin/server/config/config.module#EgAdminServerConfigModule'
+}];
+
+@NgModule({
+ imports: [RouterModule.forChild(routes)],
+ exports: [RouterModule]
+})
+
+export class EgAdminServerRoutingModule {}
import {EgToastComponent} from '@eg/share/toast/toast.component';
import {EgStringComponent} from '@eg/share/string/string.component';
import {EgStringService} from '@eg/share/string/string.service';
+import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
/**
* Imports the EG common modules and adds modules common to all staff UI's.
EgAccessKeyInfoComponent,
EgToastComponent,
EgStringComponent,
- EgOpChangeComponent
+ EgOpChangeComponent,
+ FmRecordEditorComponent
],
imports: [
EgCommonModule
EgAccessKeyInfoComponent,
EgToastComponent,
EgStringComponent,
- EgOpChangeComponent
+ EgOpChangeComponent,
+ FmRecordEditorComponent
]
})
import {EgStaffCommonModule} from '@eg/staff/common.module';
import {EgSandboxRoutingModule} from './routing.module';
import {EgSandboxComponent} from './sandbox.component';
-import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
import {EgGridModule} from '@eg/share/grid/grid.module';
@NgModule({
declarations: [
- EgSandboxComponent,
- FmRecordEditorComponent
+ EgSandboxComponent
],
imports: [
EgStaffCommonModule,