Browse Source

Merge pull request #1572 from abpframework/fix/modal-compenent

Fix/modal compenent
pull/1574/head
Yasin Aydın 7 years ago
committed by GitHub
parent
commit
03d16da00d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      npm/ng-packs/packages/core/src/lib/plugins/config.plugin.ts
  2. 8
      npm/ng-packs/packages/theme-basic/src/lib/components/layout/layout.component.html
  3. 2
      npm/ng-packs/packages/theme-basic/src/lib/components/layout/layout.component.ts
  4. 8
      npm/ng-packs/packages/theme-shared/src/lib/abstracts/toaster.ts
  5. 1
      npm/ng-packs/packages/theme-shared/src/lib/animations/index.ts
  6. 6
      npm/ng-packs/packages/theme-shared/src/lib/animations/slide.animation.ts
  7. 5
      npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.html
  8. 27
      npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.ts
  9. 8
      npm/ng-packs/packages/theme-shared/src/lib/services/confirmation.service.ts
  10. 4
      npm/ng-packs/packages/theme-shared/src/lib/services/toaster.service.ts
  11. 1
      npm/ng-packs/packages/theme-shared/src/public-api.ts
  12. 2
      npm/ng-packs/scripts/build.js
  13. 3
      npm/ng-packs/scripts/sync.js
  14. 4
      templates/app/angular/src/app/app.component.ts

10
npm/ng-packs/packages/core/src/lib/plugins/config.plugin.ts

@ -1,9 +1,9 @@
import { Injectable, Inject, InjectionToken, Type } from '@angular/core'; import { Inject, Injectable, InjectionToken } from '@angular/core';
import { NgxsPlugin, setValue, actionMatcher, InitState, UpdateState, NgxsNextPluginFn } from '@ngxs/store';
import { Router, Routes } from '@angular/router'; import { Router, Routes } from '@angular/router';
import { ABP } from '../models'; import { actionMatcher, InitState, NgxsNextPluginFn, NgxsPlugin, setValue, UpdateState } from '@ngxs/store';
import snq from 'snq'; import snq from 'snq';
import { setChildRoute, sortRoutes, organizeRoutes } from '../utils/route-utils'; import { ABP } from '../models';
import { organizeRoutes } from '../utils/route-utils';
export const NGXS_CONFIG_PLUGIN_OPTIONS = new InjectionToken('NGXS_CONFIG_PLUGIN_OPTIONS'); export const NGXS_CONFIG_PLUGIN_OPTIONS = new InjectionToken('NGXS_CONFIG_PLUGIN_OPTIONS');
@ -45,7 +45,7 @@ function transformRoutes(routes: Routes = [], wrappers: ABP.FullRoute[] = []): a
wrappers = abpRoutes.filter(ar => ar.wrapper); wrappers = abpRoutes.filter(ar => ar.wrapper);
const transformed = [] as ABP.FullRoute[]; const transformed = [] as ABP.FullRoute[];
routes routes
.filter(route => route.component || route.loadChildren) .filter(route => route.component || route.loadChildren || (route.data || {}).routes)
.forEach(route => { .forEach(route => {
const abpPackage = abpRoutes.find(abp => abp.path.toLowerCase() === route.path.toLowerCase()); const abpPackage = abpRoutes.find(abp => abp.path.toLowerCase() === route.path.toLowerCase());
const { length } = transformed; const { length } = transformed;

8
npm/ng-packs/packages/theme-basic/src/lib/components/layout/layout.component.html

@ -8,8 +8,12 @@
</div> </div>
</nav> </nav>
<div style="padding-top: 5rem;" class="container"> <div
<router-outlet></router-outlet> [@routeAnimations]="outlet && outlet.activatedRoute && outlet.activatedRoute.routeConfig.path"
style="padding-top: 5rem;"
class="container"
>
<router-outlet #outlet="outlet"></router-outlet>
</div> </div>
<abp-confirmation></abp-confirmation> <abp-confirmation></abp-confirmation>

2
npm/ng-packs/packages/theme-basic/src/lib/components/layout/layout.component.ts

@ -1,8 +1,10 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { slideFromBottom } from '@abp/ng.theme.shared';
@Component({ @Component({
selector: ' abp-layout', selector: ' abp-layout',
templateUrl: './layout.component.html', templateUrl: './layout.component.html',
animations: [slideFromBottom],
}) })
export class LayoutComponent { export class LayoutComponent {
isCollapsed: boolean = false; isCollapsed: boolean = false;

8
npm/ng-packs/packages/theme-shared/src/lib/abstracts/toaster.ts

@ -2,12 +2,12 @@ import { MessageService } from 'primeng/components/common/messageservice';
import { Observable, Subject } from 'rxjs'; import { Observable, Subject } from 'rxjs';
import { Toaster } from '../models/toaster'; import { Toaster } from '../models/toaster';
export class AbstractToasterClass<T = Toaster.Options> { export class AbstractToaster<T = Toaster.Options> {
protected status$: Subject<Toaster.Status>; status$: Subject<Toaster.Status>;
protected key: string = 'abpToast'; key: string = 'abpToast';
protected sticky: boolean = false; sticky: boolean = false;
constructor(protected messageService: MessageService) {} constructor(protected messageService: MessageService) {}
info(message: string, title: string, options?: T): Observable<Toaster.Status> { info(message: string, title: string, options?: T): Observable<Toaster.Status> {

1
npm/ng-packs/packages/theme-shared/src/lib/animations/index.ts

@ -0,0 +1 @@
export * from './slide.animation';

6
npm/ng-packs/packages/theme-shared/src/lib/animations/slide.animation.ts

@ -0,0 +1,6 @@
import { animate, state, style, transition, trigger, query } from '@angular/animations';
export const slideFromBottom = trigger('routeAnimations', [
state('void', style({ 'margin-top': '20px', opacity: '0' })),
state('*', style({ 'margin-top': '0px', opacity: '1' })),
transition(':enter', [animate('0.2s ease-out', style({ opacity: '1', 'margin-top': '0px' }))]),
]);

5
npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.html

@ -1,9 +1,8 @@
<div <div
*ngIf="showModal"
id="abp-modal" id="abp-modal"
tabindex="-1" tabindex="-1"
class="modal fade {{ modalClass }}" class="modal fade {{ modalClass }} d-block show"
[class.show]="visible"
[style.display]="visible ? 'block' : 'none'"
[style.padding-right.px]="'15'" [style.padding-right.px]="'15'"
> >
<div <div

27
npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.ts

@ -27,8 +27,13 @@ export class ModalComponent implements OnDestroy {
return this._visible; return this._visible;
} }
set visible(value: boolean) { set visible(value: boolean) {
if (typeof value !== 'boolean') return;
if (!this.modalContent) { if (!this.modalContent) {
setTimeout(() => (this.visible = value), 0); setTimeout(() => {
this.showModal = value;
this.visible = value;
}, 0);
return; return;
} }
@ -40,7 +45,7 @@ export class ModalComponent implements OnDestroy {
this.renderer.addClass(this.modalContent.nativeElement, 'fade-out-top'); this.renderer.addClass(this.modalContent.nativeElement, 'fade-out-top');
setTimeout(() => { setTimeout(() => {
this.setVisible(value); this.setVisible(value);
this.renderer.removeClass(this.modalContent.nativeElement, 'fade-out-top'); // this.renderer.removeClass(this.modalContent.nativeElement, 'fade-out-top');
this.ngOnDestroy(); this.ngOnDestroy();
}, 350); }, 350);
} }
@ -66,10 +71,12 @@ export class ModalComponent implements OnDestroy {
_visible: boolean = false; _visible: boolean = false;
closable: boolean = false; showModal: boolean = false;
isOpenConfirmation: boolean = false; isOpenConfirmation: boolean = false;
closable: boolean = false;
destroy$ = new Subject<void>(); destroy$ = new Subject<void>();
constructor(private renderer: Renderer2, private confirmationService: ConfirmationService) {} constructor(private renderer: Renderer2, private confirmationService: ConfirmationService) {}
@ -81,6 +88,8 @@ export class ModalComponent implements OnDestroy {
setVisible(value: boolean) { setVisible(value: boolean) {
this._visible = value; this._visible = value;
this.visibleChange.emit(value); this.visibleChange.emit(value);
this.showModal = value;
value value
? timer(500) ? timer(500)
.pipe(take(1)) .pipe(take(1))
@ -93,14 +102,16 @@ export class ModalComponent implements OnDestroy {
.pipe( .pipe(
debounceTime(350), debounceTime(350),
takeUntil(this.destroy$), takeUntil(this.destroy$),
filter( filter((event: MouseEvent) => {
(event: MouseEvent) => const isOpenConfirmation = this.isOpenConfirmation || document.querySelector('p-toastitem');
return (
event && event &&
this.closable && this.closable &&
this.modalContent && this.modalContent &&
!this.isOpenConfirmation && !isOpenConfirmation &&
!this.modalContent.nativeElement.contains(event.target), !this.modalContent.nativeElement.contains(event.target)
), );
}),
) )
.subscribe(_ => { .subscribe(_ => {
this.close(); this.close();

8
npm/ng-packs/packages/theme-shared/src/lib/services/confirmation.service.ts

@ -1,10 +1,10 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AbstractToasterClass } from '../abstracts/toaster'; import { AbstractToaster } from '../abstracts/toaster';
import { Confirmation } from '../models/confirmation'; import { Confirmation } from '../models/confirmation';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class ConfirmationService extends AbstractToasterClass<Confirmation.Options> { export class ConfirmationService extends AbstractToaster<Confirmation.Options> {
protected key: string = 'abpConfirmation'; key: string = 'abpConfirmation';
protected sticky: boolean = true; sticky: boolean = true;
} }

4
npm/ng-packs/packages/theme-shared/src/lib/services/toaster.service.ts

@ -1,9 +1,9 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AbstractToasterClass } from '../abstracts/toaster'; import { AbstractToaster } from '../abstracts/toaster';
import { Message } from 'primeng/components/common/message'; import { Message } from 'primeng/components/common/message';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class ToasterService extends AbstractToasterClass { export class ToasterService extends AbstractToaster {
addAll(messages: Message[]): void { addAll(messages: Message[]): void {
this.messageService.addAll(messages.map(message => ({ key: this.key, ...message }))); this.messageService.addAll(messages.map(message => ({ key: this.key, ...message })));
} }

1
npm/ng-packs/packages/theme-shared/src/public-api.ts

@ -3,6 +3,7 @@
*/ */
export * from './lib/theme-shared.module'; export * from './lib/theme-shared.module';
export * from './lib/animations';
export * from './lib/components'; export * from './lib/components';
export * from './lib/models'; export * from './lib/models';
export * from './lib/services'; export * from './lib/services';

2
npm/ng-packs/scripts/build.js

@ -35,4 +35,6 @@ import fse from 'fs-extra';
cwd: '../', cwd: '../',
}); });
}); });
process.exit(0);
})(); })();

3
npm/ng-packs/scripts/sync.js

@ -1,5 +1,4 @@
// ESM syntax is supported. // ESM syntax is supported.
import execa from 'execa';
import fse from 'fs-extra'; import fse from 'fs-extra';
(async () => { (async () => {
@ -21,4 +20,6 @@ import fse from 'fs-extra';
await fse.writeJSON(srcPackagePath, { ...srcPackage, version }, { spaces: 2 }); await fse.writeJSON(srcPackagePath, { ...srcPackage, version }, { spaces: 2 });
}); });
process.exit(0);
})(); })();

4
templates/app/angular/src/app/app.component.ts

@ -7,6 +7,4 @@ import { Component } from '@angular/core';
<router-outlet></router-outlet> <router-outlet></router-outlet>
`, `,
}) })
export class AppComponent { export class AppComponent {}
title = 'myProjectName';
}

Loading…
Cancel
Save