Browse Source

fix: some bugs

pull/1858/head
mehmet-erim 7 years ago
parent
commit
efb6c456f6
  1. 14
      npm/ng-packs/packages/core/src/lib/models/application-configuration.ts
  2. 35
      npm/ng-packs/packages/core/src/lib/states/config.state.ts
  3. 2
      npm/ng-packs/packages/theme-basic/src/lib/components/layout/layout.component.html
  4. 9
      npm/ng-packs/packages/theme-shared/src/lib/animations/slide.animations.ts
  5. 11
      npm/ng-packs/packages/theme-shared/src/lib/components/button/button.component.ts

14
npm/ng-packs/packages/core/src/lib/models/application-configuration.ts

@ -1,10 +1,12 @@
import { ABP } from './common';
export namespace ApplicationConfiguration {
export interface Response {
localization: Localization;
auth: Auth;
setting: Setting;
setting: Value;
currentUser: CurrentUser;
features: Features;
features: Value;
}
export interface Localization {
@ -32,8 +34,8 @@ export namespace ApplicationConfiguration {
[key: string]: boolean;
}
export interface Setting {
values: { [key: string]: 'Abp.Localization.DefaultLanguage' };
export interface Value {
values: ABP.Dictionary<string>;
}
export interface CurrentUser {
@ -42,8 +44,4 @@ export namespace ApplicationConfiguration {
tenantId: string;
userName: string;
}
export interface Features {
values: Setting;
}
}

35
npm/ng-packs/packages/core/src/lib/states/config.state.ts

@ -1,14 +1,14 @@
import { State, Selector, createSelector, Action, StateContext, Store } from '@ngxs/store';
import { Config } from '../models/config';
import { ABP } from '../models/common';
import { GetAppConfiguration, PatchRouteByName } from '../actions/config.actions';
import { ApplicationConfigurationService } from '../services/application-configuration.service';
import { tap, switchMap } from 'rxjs/operators';
import { Action, createSelector, Selector, State, StateContext, Store } from '@ngxs/store';
import { of } from 'rxjs';
import { switchMap, tap } from 'rxjs/operators';
import snq from 'snq';
import { GetAppConfiguration, PatchRouteByName } from '../actions/config.actions';
import { SetLanguage } from '../actions/session.actions';
import { ABP } from '../models/common';
import { Config } from '../models/config';
import { ApplicationConfigurationService } from '../services/application-configuration.service';
import { organizeRoutes } from '../utils/route-utils';
import { SessionState } from './session.state';
import { of } from 'rxjs';
import { setChildRoute, sortRoutes, organizeRoutes } from '../utils/route-utils';
@State<Config.State>({
name: 'ConfigState',
@ -90,14 +90,31 @@ export class ConfigState {
return selector;
}
static getSetting(key: string) {
static getSetting(key: string, findContain?: boolean) {
const selector = createSelector(
[ConfigState],
(state: Config.State) => {
return snq(() => state.setting.values[key]);
},
);
return selector;
}
static getSettings(keyword?: string) {
const selector = createSelector(
[ConfigState],
(state: Config.State) => {
if (keyword) {
const keys = snq(() => Object.keys(state.setting.values).filter(key => key.indexOf(keyword) > -1), []);
if (keys.length) {
return keys.reduce((acc, key) => ({ ...acc, [key]: state.setting.values[key] }), {});
}
}
return snq(() => state.setting.values, {});
},
);
return selector;
}

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

@ -11,7 +11,7 @@
</nav>
<div
[@routeAnimations]="outlet && outlet.activatedRoute && outlet.activatedRoute.routeConfig.path"
[@slideFromBottom]="outlet && outlet.activatedRoute && outlet.activatedRoute.routeConfig.path"
style="padding-top: 5rem;"
class="container"
>

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

@ -1,6 +1,7 @@
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' }))]),
export const slideFromBottom = trigger('slideFromBottom', [
transition('* <=> *', [
style({ 'margin-top': '20px', opacity: '0' }),
animate('0.2s ease-out', style({ opacity: '1', 'margin-top': '0px' })),
]),
]);

11
npm/ng-packs/packages/theme-shared/src/lib/components/button/button.component.ts

@ -3,17 +3,17 @@ import { Component, Input } from '@angular/core';
@Component({
selector: 'abp-button',
template: `
<button [attr.type]="type" [ngClass]="buttonClass" [disabled]="loading || disabled">
<button [attr.type]="buttonType || type" [ngClass]="buttonClass" [disabled]="loading || disabled">
<i [ngClass]="icon" class="mr-1"></i><ng-content></ng-content>
</button>
`
`,
})
export class ButtonComponent {
@Input()
buttonClass = 'btn btn-primary';
@Input()
type = 'button';
buttonType = 'button';
@Input()
iconClass: string;
@ -24,6 +24,11 @@ export class ButtonComponent {
@Input()
disabled = false;
/**
* @deprecated Use buttonType instead. To be deleted in v1
*/
@Input() type = 'button';
get icon(): string {
return `${this.loading ? 'fa fa-pulse fa-spinner' : this.iconClass || 'd-none'}`;
}

Loading…
Cancel
Save