diff --git a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/not-found-template.directive.ts b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/directives/not-found-template.directive.ts similarity index 100% rename from projects/poweredsoft/ng-select/src/lib/ps-ng-select/not-found-template.directive.ts rename to projects/poweredsoft/ng-select/src/lib/ps-ng-select/directives/not-found-template.directive.ts diff --git a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/select-label-template.directive.ts b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/directives/select-label-template.directive.ts similarity index 70% rename from projects/poweredsoft/ng-select/src/lib/ps-ng-select/select-label-template.directive.ts rename to projects/poweredsoft/ng-select/src/lib/ps-ng-select/directives/select-label-template.directive.ts index 55dc0a1..7c667a0 100644 --- a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/select-label-template.directive.ts +++ b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/directives/select-label-template.directive.ts @@ -1,4 +1,4 @@ -import { Directive, TemplateRef, Input } from '@angular/core'; +import { Directive, TemplateRef } from '@angular/core'; @Directive({ selector: '[psNgSelectLabel]' diff --git a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/select-option-template.directive.ts b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/directives/select-option-template.directive.ts similarity index 100% rename from projects/poweredsoft/ng-select/src/lib/ps-ng-select/select-option-template.directive.ts rename to projects/poweredsoft/ng-select/src/lib/ps-ng-select/directives/select-option-template.directive.ts diff --git a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/multi-select/multi-select.component.ts b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/multi-select/multi-select.component.ts index e45ecfc..c976dfa 100644 --- a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/multi-select/multi-select.component.ts +++ b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/multi-select/multi-select.component.ts @@ -1,11 +1,11 @@ import { Component, OnInit, ContentChild, ViewChild, Input, Output, EventEmitter, ChangeDetectorRef, forwardRef, OnDestroy } from '@angular/core'; -import { SelectLabelTemplateDirective } from '../select-label-template.directive'; +import { SelectLabelTemplateDirective } from '../directives/select-label-template.directive'; import { IDataSource, ISimpleFilter } from '@poweredsoft/data'; import { Observable, Subject, Subscription } from 'rxjs'; import { map, distinctUntilChanged, debounceTime } from 'rxjs/operators'; import { NgSelectComponent as SelectComponent } from '@ng-select/ng-select'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; -import { SelectOptionTemplateDirective } from '../select-option-template.directive'; +import { SelectOptionTemplateDirective } from '../directives/select-option-template.directive'; @Component({ selector: 'ps-ng-multi-select', diff --git a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ng-select/ng-select.component.ts b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ng-select/ng-select.component.ts index 9b3cb33..a3502c2 100644 --- a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ng-select/ng-select.component.ts +++ b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ng-select/ng-select.component.ts @@ -1,12 +1,12 @@ import { Component, OnInit, ContentChild, ViewChild, Input, Output, EventEmitter, ChangeDetectorRef, forwardRef, OnDestroy } from '@angular/core'; -import { SelectLabelTemplateDirective } from '../select-label-template.directive'; +import { SelectLabelTemplateDirective } from '../directives/select-label-template.directive'; import { IDataSource, ISimpleFilter } from '@poweredsoft/data'; import { Observable, Subject, Subscription } from 'rxjs'; import { map, distinctUntilChanged, debounceTime } from 'rxjs/operators'; import { NgSelectComponent as SelectComponent } from '@ng-select/ng-select'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; -import { SelectOptionTemplateDirective } from '../select-option-template.directive'; -import { NotFoundTemplateDirective } from '../not-found-template.directive'; +import { SelectOptionTemplateDirective } from '../directives/select-option-template.directive'; +import { NotFoundTemplateDirective } from '../directives/not-found-template.directive'; @Component({ diff --git a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ps-ng-select.module.ts b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ps-ng-select.module.ts index a833cda..3b89b59 100644 --- a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ps-ng-select.module.ts +++ b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ps-ng-select.module.ts @@ -4,9 +4,9 @@ import { NgSelectComponent } from './ng-select/ng-select.component'; import { MultiSelectComponent } from './multi-select/multi-select.component'; import { FormsModule } from '@angular/forms'; import { NgSelectModule } from '@ng-select/ng-select'; -import { SelectLabelTemplateDirective } from './select-label-template.directive'; -import { SelectOptionTemplateDirective } from './select-option-template.directive'; -import { NotFoundTemplateDirective } from './not-found-template.directive'; +import { SelectLabelTemplateDirective } from './directives/select-label-template.directive'; +import { SelectOptionTemplateDirective } from './directives/select-option-template.directive'; +import { NotFoundTemplateDirective } from './directives/not-found-template.directive'; diff --git a/projects/poweredsoft/ng-select/src/public-api.ts b/projects/poweredsoft/ng-select/src/public-api.ts index 8c65c66..7a883ee 100644 --- a/projects/poweredsoft/ng-select/src/public-api.ts +++ b/projects/poweredsoft/ng-select/src/public-api.ts @@ -5,6 +5,6 @@ export * from './lib/ps-ng-select/ps-ng-select.module'; export * from './lib/ps-ng-select/ng-select/ng-select.component'; export * from './lib/ps-ng-select/multi-select/multi-select.component'; -export * from './lib/ps-ng-select/select-label-template.directive'; -export * from './lib/ps-ng-select/select-option-template.directive'; -export * from './lib/ps-ng-select/not-found-template.directive'; +export * from './lib/ps-ng-select/directives/select-label-template.directive'; +export * from './lib/ps-ng-select/directives/select-option-template.directive'; +export * from './lib/ps-ng-select/directives/not-found-template.directive'; diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal.module.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal.module.ts index 0940f87..c80c5da 100644 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal.module.ts +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal.module.ts @@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common'; import { ModalModule } from 'ngx-bootstrap/modal'; import { CommandModalDirective } from './directives/command-modal.directive'; import { CommandModalComponent } from './command-modal/command-modal.component'; -import { InputValidatorDirective } from './directives/input-validator.directive'; + import { FormsModule } from '@angular/forms'; @NgModule({ @@ -12,7 +12,7 @@ import { FormsModule } from '@angular/forms'; ModalModule.forRoot(), FormsModule ], - declarations: [CommandModalDirective, CommandModalComponent, InputValidatorDirective], + declarations: [CommandModalDirective, CommandModalComponent], exports: [CommandModalDirective] }) export class CommandModalModule { } diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.spec.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.spec.ts deleted file mode 100644 index 89276ef..0000000 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { CommandModalComponent } from './command-modal.component'; - -describe('CommandModalComponent', () => { - let component: CommandModalComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ CommandModalComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(CommandModalComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.ts index 4408a68..3e37018 100644 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.ts +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, TemplateRef, OnDestroy } from '@angular/core'; +import { Component, OnInit, TemplateRef, OnDestroy, EventEmitter } from '@angular/core'; import { IDataSource } from '@poweredsoft/data'; import { BsModalRef } from 'ngx-bootstrap/modal'; import { finalize} from 'rxjs/operators'; @@ -24,6 +24,8 @@ export class CommandModalComponent implements OnInit, OnDestroy { form:NgForm; validationMessage:string ; + successEmitter: EventEmitter; + private _notifyMessage: Subscription; private _validationError: Subscription; @@ -62,11 +64,12 @@ export class CommandModalComponent implements OnInit, OnDestroy { this.loading = false; }) ) - .subscribe(success => { + .subscribe(commandResult => { if (this.refreshOnSuccess) this.dataSource.refresh(); this.modalRef.hide(); + this.successEmitter.emit(commandResult); }, fail => { // you do not want to close on failure.. so just ignore.. }); diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/directives/command-modal.directive.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/directives/command-modal.directive.ts index c7c7418..02b45a3 100644 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/directives/command-modal.directive.ts +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/directives/command-modal.directive.ts @@ -1,4 +1,4 @@ -import { Directive, HostListener, Input, TemplateRef } from '@angular/core'; +import { Directive, HostListener, Input, TemplateRef, Output, EventEmitter } from '@angular/core'; import { IDataSource } from '@poweredsoft/data'; import { BsModalService } from 'ngx-bootstrap/modal'; import { CommandModalComponent } from '../command-modal/command-modal.component'; @@ -21,6 +21,8 @@ export class CommandModalDirective { @Input() cancelText: string; @Input() animated: boolean; + @Output() success: EventEmitter = new EventEmitter(); + @HostListener('click') wasClicked() { this.dataSource.resolveCommandModelByName({ @@ -35,7 +37,8 @@ export class CommandModalDirective { title: this.commandTitle, refreshOnSuccess: this.refreshOnSuccess === undefined ? true : this.refreshOnSuccess, commandText: this.commandText || 'OK', - cancelText: this.cancelText || 'Cancel' + cancelText: this.cancelText || 'Cancel', + successEmitter: this.success }; this.modalService.show(CommandModalComponent, { animated: this.animated === undefined ? true : this.animated, diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/directives/input-validator.directive.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/directives/input-validator.directive.ts deleted file mode 100644 index 8fb46d8..0000000 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/directives/input-validator.directive.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Directive } from '@angular/core'; -import { Validator, AbstractControl, ValidationErrors, NG_VALIDATORS } from '@angular/forms'; - -@Directive({ - selector: '[psbxInputValidator]', - providers: [{ provide: NG_VALIDATORS, useExisting: InputValidatorDirective, multi: true }] -}) -export class InputValidatorDirective implements Validator{ - - constructor() { } - - validate(control: AbstractControl): ValidationErrors { - throw new Error("Method not implemented."); - } - registerOnValidatorChange?(fn: () => void): void { - throw new Error("Method not implemented."); - } - -} diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/command/command.module.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/command/command.module.ts new file mode 100644 index 0000000..4ce5b10 --- /dev/null +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/command/command.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { CommandDirective } from './directives/command.directive'; +import { ConfirmModalModule } from '../confirm-modal/confirm-modal.module'; + + + +@NgModule({ + declarations: [CommandDirective], + imports: [ + CommonModule, + ConfirmModalModule + ], + exports:[CommandDirective] +}) +export class CommandModule { } diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/command/directives/command.directive.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/command/directives/command.directive.ts new file mode 100644 index 0000000..5d042ba --- /dev/null +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/command/directives/command.directive.ts @@ -0,0 +1,70 @@ +import { Directive, Input, TemplateRef, HostListener, Output, EventEmitter } from '@angular/core'; +import { IDataSource } from '@poweredsoft/data'; +import { ConfirmModalService } from '../../confirm-modal/confirm-modal.service'; + +@Directive({ + selector: '[psbxCommand]' +}) +export class CommandDirective { + + constructor(private confirmModalService: ConfirmModalService) { } + + + @Input() dataSource: IDataSource; + @Input() command: string; + @Input() model: any; + @Input() refreshOnSuccess: boolean; + @Input() animated: boolean; + + @Input() confirm: boolean; + @Input() confirmMessage: string; + @Input() yesText: string; + @Input() noText: string; + @Input() yesClass: string; + @Input() noClass: string; + + @Output() success: EventEmitter = new EventEmitter(); + @Output() failure: EventEmitter = new EventEmitter(); + + private doCommand() { + this.dataSource.resolveCommandModelByName({ + command: this.command, + model: this.model + }).subscribe(commandModel => { + this.dataSource.executeCommandByName(this.command, commandModel).subscribe( + commandResult => { + if (this.refreshOnSuccess !== false) + this.dataSource.refresh(); + + this.success.emit(commandResult); + }, + commandError => { + this.failure.emit(commandError); + } + ); + }, resolveCommandError => { + this.failure.emit(resolveCommandError); + }); + } + + + @HostListener('click') + wasClicked() { + + if (this.confirm) { + this.confirmModalService.confirm({ + message: this.confirmMessage, + yesText: this.yesText || 'yes', + yesClass: this.yesClass || 'danger', + noText: this.noText || 'no', + noClass: this.noClass || 'light', + }).subscribe(result => { + if (result) + this.doCommand(); + }) + } else { + this.doCommand(); + } + } + +} diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/confirm-modal/confirm-modal-components/confirm-modal/confirm-modal.component.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/confirm-modal/confirm-modal-components/confirm-modal/confirm-modal.component.ts index 7259d73..3047239 100644 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/confirm-modal/confirm-modal-components/confirm-modal/confirm-modal.component.ts +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/confirm-modal/confirm-modal-components/confirm-modal/confirm-modal.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, TemplateRef } from '@angular/core'; +import { Component, OnInit, TemplateRef, EventEmitter } from '@angular/core'; import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; import { Observer } from 'rxjs'; @@ -27,11 +27,11 @@ export class ConfirmModalComponent implements OnInit { } get yesButtonClass() { - return `btn btn-sm btn-${this.yesClass}` + return `btn btn-${this.yesClass}` } get noButtonClass() { - return `btn btn-sm btn-${this.noClass}` + return `btn btn-${this.noClass}` } confirm(): void { diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/confirm-modal/confirm-modal.directive.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/confirm-modal/confirm-modal.directive.ts deleted file mode 100644 index ce53863..0000000 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/confirm-modal/confirm-modal.directive.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { Directive, Input, TemplateRef, HostListener } from '@angular/core'; -import { ConfirmModalService } from './confirm-modal.service'; -import { IDataSource } from '@poweredsoft/data'; - -@Directive({ - selector: '[psbxConfirmModal]' -}) -export class ConfirmModalDirective { - - constructor(private confirmModalService: ConfirmModalService) { } - - - @Input() dataSource: IDataSource; - @Input() command: string; - @Input() model: any; - @Input() template: TemplateRef; - @Input() commandTitle: string; - @Input() refreshOnSuccess: boolean; - @Input() commandText: string; - @Input() cancelText: string; - @Input() animated: boolean; - - - @HostListener('click') - wasClicked() { - this.dataSource.resolveCommandModelByName({ - command: this.command, - model: this.model - }).subscribe(commandModel => { - this.confirmModalService.confirm({ - message: 'Do you want to delete this merchant?', - yesText: 'yes delete this merchant', - yesClass: 'danger', - noText: 'no please dont', - noClass: 'light' - }).subscribe(result => { - if(result){ - this.dataSource.executeCommandByName(this.command, commandModel).subscribe( - res => { - this.dataSource.refresh(); - }, - err => { - console.log(err); - alert('failed'); - } - ); - } - }) - - }, error => { - - }); - } - -} diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/confirm-modal/confirm-modal.module.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/confirm-modal/confirm-modal.module.ts index fcfda3a..94314af 100644 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/confirm-modal/confirm-modal.module.ts +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/confirm-modal/confirm-modal.module.ts @@ -3,18 +3,20 @@ import { CommonModule } from '@angular/common'; import { ConfirmModalComponent } from './confirm-modal-components/confirm-modal/confirm-modal.component'; import { ModalModule } from 'ngx-bootstrap/modal'; import { ConfirmModalService } from './confirm-modal.service'; -import { ConfirmModalDirective } from './confirm-modal.directive'; +import { CommandModule } from '../command/command.module'; + @NgModule({ - declarations: [ConfirmModalComponent, ConfirmModalDirective], + declarations: [ConfirmModalComponent], imports: [ CommonModule, + //CommandModule, ModalModule.forRoot(), ], - exports:[ConfirmModalDirective], + exports:[], providers: [ConfirmModalService] }) export class ConfirmModalModule { } diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/dataSource-filter/data-source-filter.module.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/data-source-filter/data-source-filter.module.ts similarity index 100% rename from projects/poweredsoft/ngx-bootstrap/src/lib/dataSource-filter/data-source-filter.module.ts rename to projects/poweredsoft/ngx-bootstrap/src/lib/data-source-filter/data-source-filter.module.ts diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/dataSource-filter/datetime-filter/data-source-datetime-filter.component.html b/projects/poweredsoft/ngx-bootstrap/src/lib/data-source-filter/datetime-filter/data-source-datetime-filter.component.html similarity index 54% rename from projects/poweredsoft/ngx-bootstrap/src/lib/dataSource-filter/datetime-filter/data-source-datetime-filter.component.html rename to projects/poweredsoft/ngx-bootstrap/src/lib/data-source-filter/datetime-filter/data-source-datetime-filter.component.html index ce785ac..9e7a508 100644 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/dataSource-filter/datetime-filter/data-source-datetime-filter.component.html +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/data-source-filter/datetime-filter/data-source-datetime-filter.component.html @@ -1,4 +1,5 @@ +
- + bsDatepicker [(ngModel)]="filterValue" [ngModelOptions]="{standalone: true}">
+
- + bsDaterangepicker [(ngModel)]="filterValue" [ngModelOptions]="{standalone: true}">
- - - +
- + - +
+
+ +