penambahan form input tambah cost management

This commit is contained in:
2024-04-21 21:55:16 +07:00
parent 4f4dde0d07
commit 4dc2c3f1a7
10 changed files with 746 additions and 63 deletions

View File

@@ -1,15 +1,13 @@
<div class="app-content content">
<div class="content-overlay"></div>
<div class="content-wrapper">
<div class="content-header row"></div>
<div class="content-header row mb-1">
<app-breadcrumb class="col-12" [breadcrumb]="breadcrumb"></app-breadcrumb>
</div>
<div class="content-body">
<section id="basic-form-layouts">
<div class="row" matchHeight="card">
<div class="col-md-6" *blockUI="'projectInfo'; message: 'Loading'">
<m-card
[options]="options"
(reloadFunction)="reloadProjectInfo($event)"
>
<div class="row">
<div class="col-12" *blockUI="'projectInfo'; message: 'Loading'">
<m-card>
<ng-container mCardHeaderTitle>
<h2>
{{
@@ -445,4 +443,4 @@
</div>
</div>
</div>
<!-- END: Content-->

View File

@@ -1,4 +1,4 @@
import { Component, ViewChild } from "@angular/core";
import { Component, OnInit, ViewChild } from "@angular/core";
import { FormBuilder, FormGroup, NgForm, Validators } from "@angular/forms";
import { ActivatedRoute, Router } from "@angular/router";
import { BlockUI, NgBlockUI } from "ng-block-ui";
@@ -8,7 +8,7 @@ import { BlockUI, NgBlockUI } from "ng-block-ui";
templateUrl: "./add-edit-device.component.html",
styleUrls: ["./add-edit-device.component.css"],
})
export class AddEditDeviceComponent {
export class AddEditDeviceComponent implements OnInit{
@ViewChild("f", { read: true }) userProfileForm: NgForm;
model: any = {};
@@ -59,27 +59,8 @@ export class AddEditDeviceComponent {
ngOnInit() {
this.route.data.subscribe((data) => {
this.mode = data.mode;
console.log(this.mode);
});
this.breadcrumb = {
mainlabel: "Basic Forms",
links: [
{
name: "Home",
isLink: true,
link: "/dashboard/sales",
},
{
name: "Form Layouts",
isLink: true,
link: "#",
},
{
name: "Basic Forms",
isLink: false,
},
],
};
this.setBreadcrumb()
this.projectInfo = this.formBuilder.group({
firstName: ["", Validators.required],
@@ -94,6 +75,64 @@ export class AddEditDeviceComponent {
});
}
setBreadcrumb() {
if (this.isAddMode()) {
this.breadcrumb = {
mainlabel: "Device",
links: [
{
name: "Home",
isLink: false,
},
{
name: "Device",
isLink: false,
},
{
name: "Add new device",
isLink: false,
},
],
};
} else if (this.isEditMode()) {
this.breadcrumb = {
mainlabel: "Device",
links: [
{
name: "Home",
isLink: false,
},
{
name: "Device",
isLink: false,
},
{
name: "Edit new device",
isLink: false,
},
],
};
} else if (this.isViewMode()) {
this.breadcrumb = {
mainlabel: "Device",
links: [
{
name: "Home",
isLink: false,
},
{
name: "Device",
isLink: false,
},
{
name: "View new device",
isLink: false,
},
],
};
}
}
isEditMode() {
return this.mode === "edit";
}
@@ -112,31 +151,13 @@ export class AddEditDeviceComponent {
onProjectInfoSubmit() {
this.submitted = true;
if (this.projectInfo.invalid) {
return;
}
}
reloadProjectInfo() {
this.blockUIProjectInfo.start("Loading..");
setTimeout(() => {
this.blockUIProjectInfo.stop();
}, 2500);
}
reloadUserProfile() {
this.blockUIUserProfile.start("Loading..");
setTimeout(() => {
this.blockUIUserProfile.stop();
}, 2500);
}
keyPress(event: any) {
const pattern = /[0-9\+\-\ ]/;
const inputChar = String.fromCharCode(event.charCode);
if (event.keyCode !== 8 && !pattern.test(inputChar)) {
event.preventDefault();
@@ -146,6 +167,6 @@ export class AddEditDeviceComponent {
addData() {}
cancel() {
this.router.navigate(["/device"]); // Adjust the path as per your routing setup
this.router.navigate(["/device"]);
}
}