diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/form-group-command-modal/directives/form-group-command-modal.directive.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/form-group-command-modal/directives/form-group-command-modal.directive.ts index 90cfdb2..a998d50 100644 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/form-group-command-modal/directives/form-group-command-modal.directive.ts +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/form-group-command-modal/directives/form-group-command-modal.directive.ts @@ -39,9 +39,7 @@ export class FormGroupCommandModalDirective { command: this.command, model: this.model }).subscribe(commandModel => { - - - + debugger; const event = { commandName: this.command, viewModel: this.model, diff --git a/src/app/data/services/IChangeMerchantNameCommand.ts b/src/app/data/services/IChangeMerchantNameCommand.ts index 1441524..9cb17a6 100644 --- a/src/app/data/services/IChangeMerchantNameCommand.ts +++ b/src/app/data/services/IChangeMerchantNameCommand.ts @@ -6,3 +6,7 @@ export interface IAddMerchantCommand { name: string; address: string; } + +export interface IRemoveMerchantCommand { + merchantId: string; +} \ No newline at end of file diff --git a/src/app/data/services/merchant.service.ts b/src/app/data/services/merchant.service.ts index 9ebe7ec..f02dad5 100644 --- a/src/app/data/services/merchant.service.ts +++ b/src/app/data/services/merchant.service.ts @@ -4,7 +4,7 @@ import { IDataSource, DataSource } from '@poweredsoft/data'; import { Apollo } from 'apollo-angular'; import gql from 'graphql-tag'; import { of } from 'rxjs'; -import { IChangeMerchantNameCommand, IAddMerchantCommand } from './IChangeMerchantNameCommand'; +import { IChangeMerchantNameCommand, IAddMerchantCommand, IRemoveMerchantCommand } from './IChangeMerchantNameCommand'; import { IMerchant } from './IMerchant'; @Injectable({ @@ -27,7 +27,7 @@ export class MerchantService { (model) => model.id, { page: 1, - pageSize: 150, + pageSize: 15, }, true ); @@ -83,6 +83,31 @@ export class MerchantService { }) ); + builder.addMutation( + 'removeMerchant', //<-- command name + 'removeMerchant', //<-- graph ql mutation name + + // implementation of the command. + command => { + + return this.apollo.use('command').mutate({ + mutation: gql` + mutation executeAddMerchant($command: RemoveMerchantCommandInput) { + removeMerchant(params: $command) + } + `, + variables: { + command: command, + }, + }); + }, + + // viewModel -> transform to the form model for that command -> IChangeMerchantName + e => of({ + merchantId: e.model.id, + }) + ); + const options = builder.create(); return new DataSource(options); } diff --git a/src/app/form-group-modal-demo/form-group-modal-demo/form-group-modal-demo.component.html b/src/app/form-group-modal-demo/form-group-modal-demo/form-group-modal-demo.component.html index 8688a9f..6fd524e 100644 --- a/src/app/form-group-modal-demo/form-group-modal-demo/form-group-modal-demo.component.html +++ b/src/app/form-group-modal-demo/form-group-modal-demo/form-group-modal-demo.component.html @@ -19,11 +19,15 @@ Actions - + + + +
diff --git a/src/app/pagination-demo/pagination-demo/pagination/pagination-demo.component.html b/src/app/pagination-demo/pagination-demo/pagination/pagination-demo.component.html index 86d4878..9c56cc0 100644 --- a/src/app/pagination-demo/pagination-demo/pagination/pagination-demo.component.html +++ b/src/app/pagination-demo/pagination-demo/pagination/pagination-demo.component.html @@ -1,4 +1,3 @@ - @@ -21,8 +20,9 @@ Actions - + + @@ -30,10 +30,15 @@ - - New Name - - + + + + + Name diff --git a/src/app/pagination-demo/pagination-demo/pagination/pagination-demo.component.ts b/src/app/pagination-demo/pagination-demo/pagination/pagination-demo.component.ts index 39af576..d52a0a2 100644 --- a/src/app/pagination-demo/pagination-demo/pagination/pagination-demo.component.ts +++ b/src/app/pagination-demo/pagination-demo/pagination/pagination-demo.component.ts @@ -20,12 +20,12 @@ export class PaginationDemoComponent implements OnInit { pages:any; - newMerchant(name: string) { - this.merchantDataSource.executeCommandByName('addMerchant', { - name: name - }).subscribe( + removeMerchant(id: string) { + this.merchantDataSource.executeCommandByName('removeMerchant', { + id: id + }).subscribe( res => { - alert('it worked!'); + alert('removed!'); this.merchantDataSource.refresh(); }, err => {