Skip to content

Commit

Permalink
feat: add edit-user
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammad-haji committed Aug 15, 2018
1 parent fda9106 commit 3e00abb
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
21 changes: 20 additions & 1 deletion src/app/pages/users/edit/edit-user.component.html
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
<h1>edit user</h1>
<div class="row">
<div class="col-sm-12">
<nb-card>
<nb-card-header>{{pageTitle}}</nb-card-header>
<nb-card-body>
<div class="row">
<div *ngFor="let form of objectKeys(formList)" class="{{formList[form].containerClass}}">
<nb-card>
<nb-card-header>{{formList[form].title}}</nb-card-header>
<nb-card-body>
<sf-form [schema]="formList[form].schema">
</sf-form>
</nb-card-body>
</nb-card>
</div>
</div>
</nb-card-body>
</nb-card>
</div>
</div>
28 changes: 26 additions & 2 deletions src/app/pages/users/edit/edit-user.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
import {Component} from '@angular/core';
import {Component, OnInit} from '@angular/core';
import {ApiDataProviderService} from "../../../@core/services/api/api-data-provider.service";
import {ActivatedRoute} from "@angular/router";
import * as _ from "lodash";

@Component({
selector: 'ngx-edit-user-component',
styleUrls: ['./edit-user.component.scss'],
templateUrl: './edit-user.component.html',
})
export class EditUserComponent {
export class EditUserComponent implements OnInit {
pageTitle: string = '';
formList: any = {}; // title
objectKeys = Object.keys;

constructor(private activatedRoute: ActivatedRoute) {
}

ngOnInit() {
this.initPageWithConfig(_.cloneDeep(this.activatedRoute.snapshot.data));
}


private initPageWithConfig(config): void {
this.pageTitle = config.pageTitle;
Object.keys(config.forms).forEach(FORM_KEY => {
config.forms[FORM_KEY].schema.subscribe(res => {
this.formList[FORM_KEY] = config.forms[FORM_KEY];
this.formList[FORM_KEY].schema = res;
})
});
}
}

0 comments on commit 3e00abb

Please sign in to comment.