Browse Source

refactor(theme-basic): rename actions and change imports from ng.core

pull/1612/head
TheDiaval 7 years ago
parent
commit
49d778f2bd
  1. 4
      npm/ng-packs/packages/theme-basic/src/lib/actions/layout.actions.ts
  2. 14
      npm/ng-packs/packages/theme-basic/src/lib/components/application-layout/application-layout.component.ts
  3. 4
      npm/ng-packs/packages/theme-basic/src/lib/components/change-password/change-password.component.ts
  4. 6
      npm/ng-packs/packages/theme-basic/src/lib/components/profile/profile.component.ts
  5. 13
      npm/ng-packs/packages/theme-basic/src/lib/states/layout.state.ts

4
npm/ng-packs/packages/theme-basic/src/lib/actions/layout.actions.ts

@ -1,11 +1,11 @@
import { Layout } from '../models/layout';
export class LayoutAddNavigationElement {
export class AddNavigationElement {
static readonly type = '[Layout] Add Navigation Element';
constructor(public payload: Layout.NavigationElement | Layout.NavigationElement[]) {}
}
export class LayoutRemoveNavigationElementByName {
export class RemoveNavigationElementByName {
static readonly type = '[Layout] Remove Navigation ElementByName';
constructor(public name: string) {}
}

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

@ -1,10 +1,10 @@
import {
ABP,
ApplicationConfiguration,
ConfigGetAppConfiguration,
GetAppConfiguration,
ConfigState,
eLayoutType,
SessionSetLanguage,
SetLanguage,
SessionState,
takeUntilDestroy,
} from '@abp/ng.core';
@ -26,7 +26,7 @@ import compare from 'just-compare';
import { fromEvent, Observable } from 'rxjs';
import { debounceTime, filter, map } from 'rxjs/operators';
import snq from 'snq';
import { LayoutAddNavigationElement } from '../../actions';
import { AddNavigationElement } from '../../actions';
import { Layout } from '../../models/layout';
import { LayoutState } from '../../states';
@ -114,7 +114,7 @@ export class ApplicationLayoutComponent implements AfterViewInit, OnDestroy {
if (navigations.indexOf('LanguageRef') < 0) {
this.store.dispatch(
new LayoutAddNavigationElement([
new AddNavigationElement([
{ element: this.languageRef, order: 4, name: 'LanguageRef' },
{ element: this.currentUserRef, order: 5, name: 'CurrentUserRef' },
]),
@ -146,8 +146,8 @@ export class ApplicationLayoutComponent implements AfterViewInit, OnDestroy {
ngOnDestroy() {}
onChangeLang(cultureName: string) {
this.store.dispatch(new SessionSetLanguage(cultureName));
this.store.dispatch(new ConfigGetAppConfiguration());
this.store.dispatch(new SetLanguage(cultureName));
this.store.dispatch(new GetAppConfiguration());
}
logout() {
@ -157,7 +157,7 @@ export class ApplicationLayoutComponent implements AfterViewInit, OnDestroy {
state: { redirectUrl: this.store.selectSnapshot(RouterState).state.url },
}),
);
this.store.dispatch(new ConfigGetAppConfiguration());
this.store.dispatch(new GetAppConfiguration());
}
}

4
npm/ng-packs/packages/theme-basic/src/lib/components/change-password/change-password.component.ts

@ -1,4 +1,4 @@
import { ProfileChangePassword } from '@abp/ng.core';
import { ChangePassword } from '@abp/ng.core';
import { ToasterService } from '@abp/ng.theme.shared';
import {
Component,
@ -63,7 +63,7 @@ export class ChangePasswordComponent implements OnInit, OnChanges {
this.store
.dispatch(
new ProfileChangePassword({
new ChangePassword({
currentPassword: this.form.get('password').value,
newPassword: this.form.get('newPassword').value,
}),

6
npm/ng-packs/packages/theme-basic/src/lib/components/profile/profile.component.ts

@ -1,4 +1,4 @@
import { Profile, ProfileGet, ProfileState, ProfileUpdate } from '@abp/ng.core';
import { Profile, GetProfile, ProfileState, UpdateProfile } from '@abp/ng.core';
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Select, Store } from '@ngxs/store';
@ -36,7 +36,7 @@ export class ProfileComponent implements OnChanges {
buildForm() {
this.store
.dispatch(new ProfileGet())
.dispatch(new GetProfile())
.pipe(
withLatestFrom(this.profile$),
take(1),
@ -55,7 +55,7 @@ export class ProfileComponent implements OnChanges {
onSubmit() {
if (this.form.invalid) return;
this.store.dispatch(new ProfileUpdate(this.form.value)).subscribe(() => {
this.store.dispatch(new UpdateProfile(this.form.value)).subscribe(() => {
this.visible = false;
this.form.reset();
});

13
npm/ng-packs/packages/theme-basic/src/lib/states/layout.state.ts

@ -1,5 +1,5 @@
import { State, Action, StateContext, Selector } from '@ngxs/store';
import { LayoutAddNavigationElement, LayoutRemoveNavigationElementByName } from '../actions/layout.actions';
import { AddNavigationElement, RemoveNavigationElementByName } from '../actions/layout.actions';
import { Layout } from '../models/layout';
import { TemplateRef } from '@angular/core';
import snq from 'snq';
@ -14,8 +14,8 @@ export class LayoutState {
return navigationElements;
}
@Action(LayoutAddNavigationElement)
layoutAddAction({ getState, patchState }: StateContext<Layout.State>, { payload = [] }: LayoutAddNavigationElement) {
@Action(AddNavigationElement)
layoutAddAction({ getState, patchState }: StateContext<Layout.State>, { payload = [] }: AddNavigationElement) {
let { navigationElements } = getState();
if (!Array.isArray(payload)) {
@ -43,11 +43,8 @@ export class LayoutState {
});
}
@Action(LayoutRemoveNavigationElementByName)
layoutRemoveAction(
{ getState, patchState }: StateContext<Layout.State>,
{ name }: LayoutRemoveNavigationElementByName,
) {
@Action(RemoveNavigationElementByName)
layoutRemoveAction({ getState, patchState }: StateContext<Layout.State>, { name }: RemoveNavigationElementByName) {
let { navigationElements } = getState();
const index = navigationElements.findIndex(element => element.name === name);

Loading…
Cancel
Save