add edit and delete object-type, group, and fields. fix bugs
parent
952fd67cba
commit
72efef88a2
|
|
@ -21,10 +21,10 @@
|
|||
<div *ngFor="let group of groups">
|
||||
<p>Группа объектов: <a [routerLink]="" target="_blank">{{group.name}}</a></p>
|
||||
<div class="right">
|
||||
<div *ngIf="!isDeleted" title="Редактировать группу" (click)="editGroup()">
|
||||
<div *ngIf="!isDeleted" title="Редактировать группу" (click)="editGroup(group.id)">
|
||||
<ico ico="edit_24" class="page-control"></ico>
|
||||
</div>
|
||||
<div *ngIf="!isDeleted" title="Удалить группу" (click)="deleteGroup()">
|
||||
<div *ngIf="!isDeleted" title="Удалить группу" (click)="deleteGroup(group.id, group.name)">
|
||||
<ico ico="visibility_off_24" class="page-control"></ico>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -35,9 +35,11 @@
|
|||
<th style="border: #1F1F1F solid 2px">type</th>
|
||||
<th style="border: #1F1F1F solid 2px">required</th>
|
||||
<th style="border: #1F1F1F solid 2px">multiple</th>
|
||||
<th style="border: #1F1F1F solid 2px">filterable</th>
|
||||
<th style="border: #1F1F1F solid 2px">hidden</th>
|
||||
<th style="border: #1F1F1F solid 2px">related</th>
|
||||
<th>
|
||||
<div *ngIf="!isDeleted" title="Добавить объект" (click)="addField()">
|
||||
<div *ngIf="!isDeleted" title="Добавить объект" (click)="addField(group.id)">
|
||||
<ico ico="webpage_plus_24" class="page-control"></ico>
|
||||
</div>
|
||||
</th>
|
||||
|
|
@ -48,14 +50,16 @@
|
|||
<td style="border: #1F1F1F solid 1px">{{field.type}}</td>
|
||||
<td style="border: #1F1F1F solid 1px">{{field.required}}</td>
|
||||
<td style="border: #1F1F1F solid 1px">{{field.multiple}}</td>
|
||||
<td style="border: #1F1F1F solid 2px">{{field.filterable}}</td>
|
||||
<td style="border: #1F1F1F solid 2px">{{field.hidden}}</td>
|
||||
<td style="border: #1F1F1F solid 1px">{{field.related}}</td>
|
||||
<td>
|
||||
<div *ngIf="!isDeleted" title="Редактировать объект" (click)="editField()">
|
||||
<div *ngIf="!isDeleted" title="Редактировать объект" (click)="editField(field.id)">
|
||||
<ico ico="edit_24" class="page-control"></ico>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div *ngIf="!isDeleted" title="Удалить объект" (click)="deleteField()">
|
||||
<div *ngIf="!isDeleted" title="Удалить объект" (click)="deleteField(field.id, field.title)">
|
||||
<ico ico="visibility_off_24" class="page-control"></ico>
|
||||
</div>
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import {DialogService} from "@app/_services/dialog.service";
|
|||
import {ObjectTypesService} from "@app/_services/object-types.service";
|
||||
import {group} from "@angular/animations";
|
||||
import {concatAll} from "rxjs/operators";
|
||||
import {GroupsService} from "@app/_services/groups.service";
|
||||
import {FieldsService} from "@app/_services/fields.service";
|
||||
|
||||
@Component({
|
||||
selector: 'object-type-list-item',
|
||||
|
|
@ -23,6 +25,8 @@ export class ObjectTypeListItemComponent {
|
|||
public objectTypesService: ObjectTypesService,
|
||||
private formsService: FormsService,
|
||||
private listsService: ListsService,
|
||||
private groupsService: GroupsService,
|
||||
private fieldsService: FieldsService,
|
||||
private dialog: DialogService) {
|
||||
}
|
||||
|
||||
|
|
@ -156,31 +160,40 @@ export class ObjectTypeListItemComponent {
|
|||
this.refresh()
|
||||
}
|
||||
|
||||
editGroup() {
|
||||
this.formsService.editModel('fieldsGroup', this.objectType.groups.id, null, this.listId);
|
||||
editGroup( id:string) {
|
||||
this.formsService.editModel('fieldsGroup', id, null, this.listId);
|
||||
this.refresh()
|
||||
}
|
||||
|
||||
deleteGroup() {
|
||||
this.dialog.confirm(`Удалить страницу ${this.objectType.groups.name}?`).subscribe(
|
||||
deleteGroup(id:string, name: string) {
|
||||
this.dialog.confirm(`Удалить группу ${name}?`).subscribe(
|
||||
resp=>{
|
||||
if (resp) this.objectTypesService.delete(this.objectType.groups.id).subscribe(res => {
|
||||
this.listsService.refresh(this.parentListId);
|
||||
if (resp) this.groupsService.delete(id).subscribe(res => {
|
||||
// this.listsService.refresh(this.parentListId);
|
||||
this.refresh();
|
||||
});
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
addField() {
|
||||
this.formsService.createModel('field'/*,{extraProps: {object_type: this.objectType.id}}*/);
|
||||
addField(id:string) {
|
||||
this.formsService.createModel('field',{extraProps: {group:id}});
|
||||
this.refresh()
|
||||
}
|
||||
|
||||
editField() {
|
||||
|
||||
editField(id:string) {
|
||||
this.formsService.editModel('field', id, null, this.listId);
|
||||
this.refresh()
|
||||
}
|
||||
|
||||
deleteField() {
|
||||
|
||||
deleteField(id:string, title: string) {
|
||||
this.dialog.confirm(`Удалить группу ${title}?`).subscribe(
|
||||
resp=>{
|
||||
if (resp) this.fieldsService.delete(id).subscribe(res => {
|
||||
// this.listsService.refresh(this.parentListId);
|
||||
this.refresh();
|
||||
});
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import {Observable} from "rxjs";
|
||||
import {environment} from "@environments/environment";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {LicenceService} from "@app/_services/licence.service";
|
||||
import {DialogService} from "@app/_services/dialog.service";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class FieldsService {
|
||||
|
||||
constructor(private http: HttpClient, private licenceService: LicenceService, private dialog: DialogService) {}
|
||||
|
||||
delete(id: string): Observable<any> {
|
||||
return this.http.delete(`${environment.apiUrl}/api/fields/${id}`);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import {Observable} from "rxjs";
|
||||
import {environment} from "@environments/environment";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {LicenceService} from "@app/_services/licence.service";
|
||||
import {DialogService} from "@app/_services/dialog.service";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class GroupsService {
|
||||
|
||||
constructor(private http: HttpClient, private licenceService: LicenceService, private dialog: DialogService) {}
|
||||
|
||||
delete(id: string): Observable<any> {
|
||||
return this.http.delete(`${environment.apiUrl}/api/group-fields/${id}`);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue