You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.4 KiB
41 lines
1.4 KiB
5 years ago
|
import { Component, OnInit, Inject } from '@angular/core';
|
||
|
import {MatTreeFlatDataSource, MatTreeFlattener} from '@angular/material/tree';
|
||
|
import {FlatTreeControl} from '@angular/cdk/tree';
|
||
|
import { HttpClient } from '@angular/common/http';
|
||
|
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
|
||
|
import {FormControl} from '@angular/forms';
|
||
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
||
|
import format from 'date-fns/format';
|
||
|
@Component({
|
||
|
selector: 'editmatlibrary',
|
||
|
templateUrl: './editmatlibrary.component.html',
|
||
|
styleUrls: ['./material-bank.component.scss']
|
||
|
})
|
||
|
export class EditMatLibrary {
|
||
|
myControl = new FormControl();
|
||
|
constructor(private http: HttpClient,public dialogRef: MatDialogRef<EditMatLibrary>,@Inject(MAT_DIALOG_DATA) public data) {}
|
||
|
name:any
|
||
|
input:any
|
||
|
ngOnInit(): void {
|
||
|
this.name = this.data.material.name
|
||
|
this.input = this.data.material.tag
|
||
|
}
|
||
|
onNoClick(): void {
|
||
|
|
||
|
this.dialogRef.close();
|
||
|
}
|
||
|
onSubmit(value){
|
||
|
let newdate = new Date();
|
||
|
let time = format(newdate, 'yyyy-MM-dd')
|
||
|
this.http.put(`/api/AssetLibraries/${this.data.material.id}`,{
|
||
|
id: this.data.material.id,
|
||
|
name: value.name,
|
||
|
order: this.data.material.order,
|
||
|
tag: value.tag,
|
||
|
enabled: true,
|
||
|
modifiedTime: time
|
||
|
}).subscribe(data=>{
|
||
|
this.dialogRef.close();
|
||
|
})
|
||
|
}
|
||
|
}
|