@qubesense/customer-farm 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +44 -0
- package/karma.conf.js +44 -0
- package/ng-package.json +7 -0
- package/package.json +11 -31
- package/src/lib/customer-farm.component.html +93 -0
- package/src/lib/customer-farm.component.scss +0 -0
- package/src/lib/customer-farm.component.ts +207 -0
- package/src/lib/customer-farm.module.ts +54 -0
- package/src/lib/customer-farm.service.ts +126 -0
- package/src/lib/dependencies/customer-farm-api-urls.ts +22 -0
- package/src/lib/dependencies/customer-farm-model.ts +52 -0
- package/{public-api.d.ts → src/public-api.ts} +4 -0
- package/src/test.ts +27 -0
- package/tsconfig.lib.json +15 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +17 -0
- package/esm2020/lib/customer-farm.component.mjs +0 -203
- package/esm2020/lib/customer-farm.module.mjs +0 -106
- package/esm2020/lib/customer-farm.service.mjs +0 -119
- package/esm2020/lib/dependencies/customer-farm-api-urls.mjs +0 -17
- package/esm2020/lib/dependencies/customer-farm-model.mjs +0 -57
- package/esm2020/public-api.mjs +0 -9
- package/esm2020/qubesense-customer-farm.mjs +0 -5
- package/fesm2015/qubesense-customer-farm.mjs +0 -525
- package/fesm2015/qubesense-customer-farm.mjs.map +0 -1
- package/fesm2020/qubesense-customer-farm.mjs +0 -502
- package/fesm2020/qubesense-customer-farm.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/customer-farm.component.d.ts +0 -79
- package/lib/customer-farm.module.d.ts +0 -24
- package/lib/customer-farm.service.d.ts +0 -57
- package/lib/dependencies/customer-farm-api-urls.d.ts +0 -8
- package/lib/dependencies/customer-farm-model.d.ts +0 -48
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../.eslintrc.json",
|
|
3
|
+
"ignorePatterns": [
|
|
4
|
+
"!**/*"
|
|
5
|
+
],
|
|
6
|
+
"overrides": [
|
|
7
|
+
{
|
|
8
|
+
"files": [
|
|
9
|
+
"*.ts"
|
|
10
|
+
],
|
|
11
|
+
"parserOptions": {
|
|
12
|
+
"project": [
|
|
13
|
+
"projects/customer-farm/tsconfig.lib.json",
|
|
14
|
+
"projects/customer-farm/tsconfig.spec.json"
|
|
15
|
+
],
|
|
16
|
+
"createDefaultProgram": true
|
|
17
|
+
},
|
|
18
|
+
"rules": {
|
|
19
|
+
"@angular-eslint/directive-selector": [
|
|
20
|
+
"error",
|
|
21
|
+
{
|
|
22
|
+
"type": "attribute",
|
|
23
|
+
"prefix": "lib",
|
|
24
|
+
"style": "camelCase"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"@angular-eslint/component-selector": [
|
|
28
|
+
"error",
|
|
29
|
+
{
|
|
30
|
+
"type": "element",
|
|
31
|
+
"prefix": "lib",
|
|
32
|
+
"style": "kebab-case"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"files": [
|
|
39
|
+
"*.html"
|
|
40
|
+
],
|
|
41
|
+
"rules": {}
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
package/karma.conf.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Karma configuration file, see link for more information
|
|
2
|
+
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
|
3
|
+
|
|
4
|
+
module.exports = function (config) {
|
|
5
|
+
config.set({
|
|
6
|
+
basePath: '',
|
|
7
|
+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
|
8
|
+
plugins: [
|
|
9
|
+
require('karma-jasmine'),
|
|
10
|
+
require('karma-chrome-launcher'),
|
|
11
|
+
require('karma-jasmine-html-reporter'),
|
|
12
|
+
require('karma-coverage'),
|
|
13
|
+
require('@angular-devkit/build-angular/plugins/karma')
|
|
14
|
+
],
|
|
15
|
+
client: {
|
|
16
|
+
jasmine: {
|
|
17
|
+
// you can add configuration options for Jasmine here
|
|
18
|
+
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
|
|
19
|
+
// for example, you can disable the random execution with `random: false`
|
|
20
|
+
// or set a specific seed with `seed: 4321`
|
|
21
|
+
},
|
|
22
|
+
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
|
23
|
+
},
|
|
24
|
+
jasmineHtmlReporter: {
|
|
25
|
+
suppressAll: true // removes the duplicated traces
|
|
26
|
+
},
|
|
27
|
+
coverageReporter: {
|
|
28
|
+
dir: require('path').join(__dirname, '../../coverage/customer-farm'),
|
|
29
|
+
subdir: '.',
|
|
30
|
+
reporters: [
|
|
31
|
+
{ type: 'html' },
|
|
32
|
+
{ type: 'text-summary' }
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
reporters: ['progress', 'kjhtml'],
|
|
36
|
+
port: 9876,
|
|
37
|
+
colors: true,
|
|
38
|
+
logLevel: config.LOG_INFO,
|
|
39
|
+
autoWatch: true,
|
|
40
|
+
browsers: ['Chrome'],
|
|
41
|
+
singleRun: false,
|
|
42
|
+
restartOnFileChange: true
|
|
43
|
+
});
|
|
44
|
+
};
|
package/ng-package.json
ADDED
package/package.json
CHANGED
|
@@ -1,32 +1,12 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@qubesense/customer-farm",
|
|
3
|
-
"license":
|
|
4
|
-
"version": "0.1.
|
|
5
|
-
"peerDependencies": {
|
|
6
|
-
"@angular/common": "^14.1.0",
|
|
7
|
-
"@angular/core": "^14.1.0"
|
|
8
|
-
},
|
|
9
|
-
"dependencies": {
|
|
10
|
-
"tslib": "^2.3.0"
|
|
11
|
-
}
|
|
12
|
-
"module": "fesm2015/qubesense-customer-farm.mjs",
|
|
13
|
-
"es2020": "fesm2020/qubesense-customer-farm.mjs",
|
|
14
|
-
"esm2020": "esm2020/qubesense-customer-farm.mjs",
|
|
15
|
-
"fesm2020": "fesm2020/qubesense-customer-farm.mjs",
|
|
16
|
-
"fesm2015": "fesm2015/qubesense-customer-farm.mjs",
|
|
17
|
-
"typings": "index.d.ts",
|
|
18
|
-
"exports": {
|
|
19
|
-
"./package.json": {
|
|
20
|
-
"default": "./package.json"
|
|
21
|
-
},
|
|
22
|
-
".": {
|
|
23
|
-
"types": "./index.d.ts",
|
|
24
|
-
"esm2020": "./esm2020/qubesense-customer-farm.mjs",
|
|
25
|
-
"es2020": "./fesm2020/qubesense-customer-farm.mjs",
|
|
26
|
-
"es2015": "./fesm2015/qubesense-customer-farm.mjs",
|
|
27
|
-
"node": "./fesm2015/qubesense-customer-farm.mjs",
|
|
28
|
-
"default": "./fesm2020/qubesense-customer-farm.mjs"
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"sideEffects": false
|
|
1
|
+
{
|
|
2
|
+
"name": "@qubesense/customer-farm",
|
|
3
|
+
"license":"qubesense",
|
|
4
|
+
"version": "0.1.2",
|
|
5
|
+
"peerDependencies": {
|
|
6
|
+
"@angular/common": "^14.1.0",
|
|
7
|
+
"@angular/core": "^14.1.0"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"tslib": "^2.3.0"
|
|
11
|
+
}
|
|
32
12
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<div class="flex flex-col flex-auto min-w-0 w-full">
|
|
2
|
+
<!-- form code starts here -->
|
|
3
|
+
<!--content-->
|
|
4
|
+
<div class="sm:w-full overflow-hidden" *ngIf="customerFarmConfiguration.showModal">
|
|
5
|
+
|
|
6
|
+
<!--form body-->
|
|
7
|
+
<form class="flex flex-col overflow-hidden" [formGroup]="customerFarmForm">
|
|
8
|
+
<!-- Customer Farm section start -->
|
|
9
|
+
|
|
10
|
+
<div class="sm:flex">
|
|
11
|
+
<div class="w-full">
|
|
12
|
+
<div class="sm:flex px-8 pt-4">
|
|
13
|
+
<mat-form-field class="flex-auto w-full mr-4"
|
|
14
|
+
*ngIf="customerFarmConfiguration.allowedCustomerFarmFields.customerName">
|
|
15
|
+
<mat-label>Client Name</mat-label>
|
|
16
|
+
<input matInput id="customerName" placeholder="Client Name" pattern="^[a-zA-Z ]*$"
|
|
17
|
+
minlength="3" [formControlName]="'customerName'" (change)="emitDataToParent()">
|
|
18
|
+
<mat-error
|
|
19
|
+
*ngIf="customerFarmForm.get('customerName').hasError('required') && customerFarmConfiguration.requiredCustomerFarmFields.customerName ">
|
|
20
|
+
Client Name is required
|
|
21
|
+
</mat-error>
|
|
22
|
+
<mat-error *ngIf="customerFarmForm.get('customerName').hasError('pattern')">
|
|
23
|
+
Please enter valid Client name
|
|
24
|
+
</mat-error>
|
|
25
|
+
<mat-error *ngIf="customerFarmForm.get('customerName').hasError('minlength')">
|
|
26
|
+
Client name must be of atleast 3 characters
|
|
27
|
+
</mat-error>
|
|
28
|
+
</mat-form-field>
|
|
29
|
+
|
|
30
|
+
<mat-form-field class="flex-auto w-full"
|
|
31
|
+
*ngIf="customerFarmConfiguration.allowedCustomerFarmFields.defaultWarehouse">
|
|
32
|
+
<mat-label>Default Warehouse</mat-label>
|
|
33
|
+
<input matInput id="defaultWarehouse" placeholder="Default Warehouse"
|
|
34
|
+
[formControlName]="'defaultWarehouse'" (change)="emitDataToParent()">
|
|
35
|
+
<mat-error
|
|
36
|
+
*ngIf="customerFarmForm.get('defaultWarehouse').hasError('required') && customerFarmConfiguration.requiredCustomerFarmFields.defaultWarehouse">
|
|
37
|
+
Default Warehouse is required
|
|
38
|
+
</mat-error>
|
|
39
|
+
</mat-form-field>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div class="sm:flex px-8 pt-4">
|
|
43
|
+
<mat-form-field class="flex-auto w-full mr-4"
|
|
44
|
+
*ngIf="customerFarmConfiguration.allowedCustomerFarmFields.personInCharge">
|
|
45
|
+
<mat-label>Person In Charge</mat-label>
|
|
46
|
+
<input matInput id="personInCharge" placeholder="Person In Charge"
|
|
47
|
+
[formControlName]="'personInCharge'" (change)="emitDataToParent()">
|
|
48
|
+
<mat-error
|
|
49
|
+
*ngIf="customerFarmForm.get('personInCharge').hasError('required') && customerFarmConfiguration.requiredCustomerFarmFields.personInCharge">
|
|
50
|
+
Person In Charge is required
|
|
51
|
+
</mat-error>
|
|
52
|
+
</mat-form-field>
|
|
53
|
+
|
|
54
|
+
<mat-form-field class="flex-auto w-full"
|
|
55
|
+
*ngIf="customerFarmConfiguration.allowedCustomerFarmFields.displayName">
|
|
56
|
+
<mat-label>Display Name</mat-label>
|
|
57
|
+
<input matInput id="displayName" placeholder="Display Name"
|
|
58
|
+
[formControlName]="'displayName'" (change)="emitDataToParent()">
|
|
59
|
+
</mat-form-field>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<div class="sm:flex px-8 pt-4">
|
|
63
|
+
<mat-form-field class="flex-auto w-full mr-4"
|
|
64
|
+
*ngIf="customerFarmConfiguration.allowedCustomerFarmFields.primaryVetId">
|
|
65
|
+
<mat-label>Primary Vet</mat-label>
|
|
66
|
+
<input matInput id="primaryVetId" placeholder="Primary Vet"
|
|
67
|
+
[formControlName]="'primaryVetId'" (change)="emitDataToParent()">
|
|
68
|
+
<mat-error
|
|
69
|
+
*ngIf="customerFarmForm.get('primaryVetId').hasError('required') && customerFarmConfiguration.requiredCustomerFarmFields.primaryVetId">
|
|
70
|
+
Primary Vet is required
|
|
71
|
+
</mat-error>
|
|
72
|
+
</mat-form-field>
|
|
73
|
+
|
|
74
|
+
<mat-form-field class="flex-auto w-full"
|
|
75
|
+
*ngIf="customerFarmConfiguration.allowedCustomerFarmFields.PICTattoo">
|
|
76
|
+
<mat-label>PIC/Tattoo (if applicable)</mat-label>
|
|
77
|
+
<input matInput id="PICTattoo" placeholder="PIC/Tattoo" [formControlName]="'PICTattoo'"
|
|
78
|
+
(change)="emitDataToParent()">
|
|
79
|
+
</mat-form-field>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
</div>
|
|
84
|
+
<!-- Customer Farm section End -->
|
|
85
|
+
|
|
86
|
+
</form>
|
|
87
|
+
</div>
|
|
88
|
+
<!-- form code ends here -->
|
|
89
|
+
|
|
90
|
+
</div>
|
|
91
|
+
<div *ngIf="customerFarmConfiguration.showGrid">
|
|
92
|
+
<lib-kendo-grid-view [configuration]="gridConfiguration" (events)="handleGridEvents($event)"></lib-kendo-grid-view>
|
|
93
|
+
</div>
|
|
File without changes
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
|
2
|
+
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
3
|
+
import { CustomerFarmConfigrationModel, CustomerFarmModel } from './dependencies/customer-farm-model';
|
|
4
|
+
import { ErrorLogService, GridEventsModel, KendoGridviewConfigurationModel, ToastrNotificationService } from '@qubesense/base-services';
|
|
5
|
+
import { CustomerFarmService } from './customer-farm.service';
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'lib-customer-farm',
|
|
9
|
+
templateUrl: './customer-farm.component.html',
|
|
10
|
+
styleUrls: ['./customer-farm.component.scss']
|
|
11
|
+
})
|
|
12
|
+
export class CustomerFarmComponent implements OnInit {
|
|
13
|
+
@Output() customerFarmData = new EventEmitter<any>();
|
|
14
|
+
@Input() public customerFarmConfiguration: CustomerFarmConfigrationModel = new CustomerFarmConfigrationModel();
|
|
15
|
+
customerFarmForm: FormGroup;
|
|
16
|
+
userMessages: string[] = [];
|
|
17
|
+
public gridData: any[] = [];
|
|
18
|
+
gridConfiguration: KendoGridviewConfigurationModel = new KendoGridviewConfigurationModel();
|
|
19
|
+
hideButtons = false;
|
|
20
|
+
isViewCall = false;
|
|
21
|
+
speciesList: any[] = [];
|
|
22
|
+
filteredCustomers:[];
|
|
23
|
+
|
|
24
|
+
constructor(private customerFarmService: CustomerFarmService,
|
|
25
|
+
private formBuilder: FormBuilder,
|
|
26
|
+
private errorLogService: ErrorLogService,
|
|
27
|
+
private toastr: ToastrNotificationService
|
|
28
|
+
) { }
|
|
29
|
+
|
|
30
|
+
ngOnInit() {
|
|
31
|
+
this.DeclareForm();
|
|
32
|
+
if (this.customerFarmConfiguration.showGrid) {
|
|
33
|
+
this.gridConfiguration.FormCode = 'CUFA';
|
|
34
|
+
this.gridConfiguration.showModal = true;
|
|
35
|
+
this.gridConfiguration.actions = { 'View': false, 'Edit': true, 'Delete': true, 'Generate PDF': false };
|
|
36
|
+
this.GetListData();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
DeclareForm() {
|
|
41
|
+
this.customerFarmForm = this.formBuilder.group({
|
|
42
|
+
recordId : [null],
|
|
43
|
+
customerId : [null],
|
|
44
|
+
customerName : [null],
|
|
45
|
+
defaultWarehouse : [null],
|
|
46
|
+
personInCharge : [null],
|
|
47
|
+
displayName : [null],
|
|
48
|
+
primaryVetId : [null],
|
|
49
|
+
PICTattoo : [null],
|
|
50
|
+
isActive : [true]
|
|
51
|
+
});
|
|
52
|
+
if (this.customerFarmConfiguration.requiredCustomerFarmFields.customerName) {
|
|
53
|
+
this.customerFarmForm.get('customerName').addValidators(Validators.required);
|
|
54
|
+
this.customerFarmForm.get('customerName').addValidators(Validators.pattern('^[a-zA-Z ]*$'));
|
|
55
|
+
this.customerFarmForm.get('customerName').addValidators(Validators.minLength(3));
|
|
56
|
+
}
|
|
57
|
+
if (this.customerFarmConfiguration.requiredCustomerFarmFields.defaultWarehouse) {
|
|
58
|
+
this.customerFarmForm.get('defaultWarehouse').addValidators(Validators.required);
|
|
59
|
+
}
|
|
60
|
+
if (this.customerFarmConfiguration.requiredCustomerFarmFields.personInCharge) {
|
|
61
|
+
this.customerFarmForm.get('personInCharge').addValidators(Validators.required);
|
|
62
|
+
}
|
|
63
|
+
if (this.customerFarmConfiguration.requiredCustomerFarmFields.primaryVetId) {
|
|
64
|
+
this.customerFarmForm.get('primaryVetId').addValidators(Validators.required);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
///////////////////////////////////standard methods/////////////////////////////////////////////////////
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @description
|
|
72
|
+
*
|
|
73
|
+
* edit data list item using data item GUID
|
|
74
|
+
*
|
|
75
|
+
* @param customerId
|
|
76
|
+
*
|
|
77
|
+
* gets customer GUID from gridData and passes it to this function
|
|
78
|
+
*/
|
|
79
|
+
async EditData(customerId:string) {
|
|
80
|
+
const getResponse = await this.customerFarmService.GetDataById(customerId);
|
|
81
|
+
this.customerFarmForm.controls['recordId'].setValue(getResponse.apiData.recordId);
|
|
82
|
+
this.customerFarmForm.controls['customerId'].setValue(getResponse.apiData.customerId);
|
|
83
|
+
this.customerFarmForm.controls['customerName'].setValue(getResponse.apiData.customerName);
|
|
84
|
+
this.customerFarmForm.controls['defaultWarehouse'].setValue(getResponse.apiData.defaultWarehouse);
|
|
85
|
+
this.customerFarmForm.controls['personInCharge'].setValue(getResponse.apiData.personInCharge);
|
|
86
|
+
this.customerFarmForm.controls['displayName'].setValue(getResponse.apiData.displayName);
|
|
87
|
+
this.customerFarmForm.controls['primaryVetId'].setValue(getResponse.apiData.primaryVetId);
|
|
88
|
+
this.customerFarmForm.controls['PICTattoo'].setValue(getResponse.apiData.PICTattoo);
|
|
89
|
+
this.customerFarmForm.controls['isActive'].setValue(getResponse.apiData.isActive);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @description
|
|
94
|
+
*
|
|
95
|
+
* this method converts all form inputs into model class
|
|
96
|
+
*
|
|
97
|
+
* @returns model with new form values
|
|
98
|
+
*/
|
|
99
|
+
ConvertFormToModel() {
|
|
100
|
+
const customerFarmModel = new CustomerFarmModel();
|
|
101
|
+
customerFarmModel.recordId = this.customerFarmForm.value.recordId;
|
|
102
|
+
customerFarmModel.customerName = this.customerFarmForm.value.customerName;
|
|
103
|
+
customerFarmModel.defaultWarehouse = this.customerFarmForm.value.defaultWarehouse;
|
|
104
|
+
customerFarmModel.personInCharge = this.customerFarmForm.value.personInCharge;
|
|
105
|
+
customerFarmModel.displayName = this.customerFarmForm.value.displayName;
|
|
106
|
+
customerFarmModel.primaryVetId = this.customerFarmForm.value.primaryVetId;
|
|
107
|
+
customerFarmModel.PICTattoo = this.customerFarmForm.value.PICTattoo;
|
|
108
|
+
customerFarmModel.customerId = this.customerFarmConfiguration.customerId;
|
|
109
|
+
customerFarmModel.formCode = this.customerFarmConfiguration.formCode;
|
|
110
|
+
|
|
111
|
+
return customerFarmModel;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @description
|
|
116
|
+
* clear form data
|
|
117
|
+
*/
|
|
118
|
+
ClearForm() {
|
|
119
|
+
this.DeclareForm();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
emitDataToParent() {
|
|
123
|
+
let customerFarmModel = new CustomerFarmModel();
|
|
124
|
+
customerFarmModel = this.ConvertFormToModel();
|
|
125
|
+
this.customerFarmData.emit(customerFarmModel);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @description
|
|
130
|
+
*
|
|
131
|
+
* Insert customer data into database
|
|
132
|
+
*/
|
|
133
|
+
public async InsertData() {
|
|
134
|
+
let customerFarmModel = new CustomerFarmModel();
|
|
135
|
+
customerFarmModel = this.ConvertFormToModel();
|
|
136
|
+
const getResponse = await this.customerFarmService.InsertData(customerFarmModel);
|
|
137
|
+
this.userMessages = getResponse.message.userMessage;
|
|
138
|
+
if (this.customerFarmConfiguration.userMessages) {
|
|
139
|
+
this.toastr.ShowSuccess(this.userMessages.toString());
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @description
|
|
145
|
+
*
|
|
146
|
+
* update customer data into database
|
|
147
|
+
*/
|
|
148
|
+
public async UpdateData() {
|
|
149
|
+
let customerFarmModel = new CustomerFarmModel();
|
|
150
|
+
customerFarmModel = this.ConvertFormToModel();
|
|
151
|
+
const getResponse = await this.customerFarmService.UpdateData(customerFarmModel);
|
|
152
|
+
this.userMessages = getResponse.message.userMessage;
|
|
153
|
+
if (this.customerFarmConfiguration.userMessages) {
|
|
154
|
+
this.toastr.ShowSuccess(this.userMessages.toString());
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @description
|
|
160
|
+
*
|
|
161
|
+
* Delete customer data into database
|
|
162
|
+
*/
|
|
163
|
+
public async DeleteData(value) {
|
|
164
|
+
const getResponse = await this.customerFarmService.DeleteData(value);
|
|
165
|
+
this.userMessages = getResponse.message.userMessage;
|
|
166
|
+
if (this.customerFarmConfiguration.userMessages) {
|
|
167
|
+
this.toastr.ShowSuccess(this.userMessages.toString());
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @description
|
|
173
|
+
*
|
|
174
|
+
* Grid events calls
|
|
175
|
+
*/
|
|
176
|
+
handleGridEvents(gridEvents: GridEventsModel) {
|
|
177
|
+
gridEvents.editRecord.subscribe((recordId) => {
|
|
178
|
+
this.hideButtons = false;
|
|
179
|
+
this.isViewCall = false;
|
|
180
|
+
this.EditData(recordId);
|
|
181
|
+
this.customerFarmForm.enable();
|
|
182
|
+
});
|
|
183
|
+
gridEvents.deleteRecord.subscribe((recordId) => {
|
|
184
|
+
this.DeleteData(recordId);
|
|
185
|
+
});
|
|
186
|
+
gridEvents.viewRecord.subscribe(async (recordId) => {
|
|
187
|
+
this.EditData(recordId);
|
|
188
|
+
this.customerFarmForm.disable();
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* @description
|
|
195
|
+
* get data for Customer grid list
|
|
196
|
+
*/
|
|
197
|
+
public async GetListData() {
|
|
198
|
+
const customerFarmModel = new CustomerFarmModel();
|
|
199
|
+
try {
|
|
200
|
+
const getResponse = await this.customerFarmService.GetListData(customerFarmModel);
|
|
201
|
+
this.gridData = getResponse.apiData;
|
|
202
|
+
} catch (error) {
|
|
203
|
+
this.errorLogService.saveError(error);
|
|
204
|
+
this.toastr.ShowAllErrors(error.error.message.userMessage);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CustomerFarmComponent } from './customer-farm.component';
|
|
3
|
+
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
4
|
+
import { CdkStepperModule } from '@angular/cdk/stepper';
|
|
5
|
+
import { CommonModule } from '@angular/common';
|
|
6
|
+
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
7
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
8
|
+
import { MatOptionModule, MatNativeDateModule } from '@angular/material/core';
|
|
9
|
+
import { MatDatepickerModule } from '@angular/material/datepicker';
|
|
10
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
11
|
+
import { MatGridListModule } from '@angular/material/grid-list';
|
|
12
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
13
|
+
import { MatInputModule } from '@angular/material/input';
|
|
14
|
+
import { MatSelectModule } from '@angular/material/select';
|
|
15
|
+
import { MatStepperModule } from '@angular/material/stepper';
|
|
16
|
+
import { MatToolbarModule } from '@angular/material/toolbar';
|
|
17
|
+
import { ButtonsModule } from '@progress/kendo-angular-buttons';
|
|
18
|
+
import { GridModule, SharedModule, ExcelModule } from '@progress/kendo-angular-grid';
|
|
19
|
+
import { KendoGridViewModule } from '@qubesense/base-services';
|
|
20
|
+
|
|
21
|
+
@NgModule({
|
|
22
|
+
declarations: [
|
|
23
|
+
CustomerFarmComponent
|
|
24
|
+
],
|
|
25
|
+
imports: [
|
|
26
|
+
MatIconModule,
|
|
27
|
+
MatInputModule,
|
|
28
|
+
MatToolbarModule,
|
|
29
|
+
ReactiveFormsModule,
|
|
30
|
+
FormsModule,
|
|
31
|
+
CommonModule,
|
|
32
|
+
GridModule,
|
|
33
|
+
ButtonsModule,
|
|
34
|
+
MatGridListModule,
|
|
35
|
+
MatFormFieldModule,
|
|
36
|
+
ReactiveFormsModule,
|
|
37
|
+
MatInputModule,
|
|
38
|
+
MatOptionModule,
|
|
39
|
+
MatSelectModule,
|
|
40
|
+
MatCheckboxModule,
|
|
41
|
+
SharedModule,
|
|
42
|
+
MatButtonModule,
|
|
43
|
+
MatDatepickerModule,
|
|
44
|
+
MatNativeDateModule,
|
|
45
|
+
ExcelModule,
|
|
46
|
+
MatStepperModule,
|
|
47
|
+
CdkStepperModule,
|
|
48
|
+
KendoGridViewModule
|
|
49
|
+
],
|
|
50
|
+
exports: [
|
|
51
|
+
CustomerFarmComponent
|
|
52
|
+
]
|
|
53
|
+
})
|
|
54
|
+
export class CustomerFarmModule { }
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { DataAccessService, WebApiResult } from '@qubesense/base-services';
|
|
3
|
+
import { CustomerFarmApiUrls } from './dependencies/customer-farm-api-urls';
|
|
4
|
+
import { CustomerFarmModel } from './dependencies/customer-farm-model';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@Injectable({
|
|
8
|
+
providedIn: 'root'
|
|
9
|
+
})
|
|
10
|
+
export class CustomerFarmService {
|
|
11
|
+
|
|
12
|
+
constructor(private dataAccessService: DataAccessService) { }
|
|
13
|
+
|
|
14
|
+
customerFarmApiUrls = new CustomerFarmApiUrls();
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* service for get customer data by Id
|
|
18
|
+
*
|
|
19
|
+
* @param customerGUID
|
|
20
|
+
*
|
|
21
|
+
* @returns Response Data from Database
|
|
22
|
+
*/
|
|
23
|
+
public async GetDataById(customerGUID: string): Promise<WebApiResult> {
|
|
24
|
+
try {
|
|
25
|
+
const url = this.customerFarmApiUrls.getCustomerFarmByIdUrl + '/' + customerGUID;
|
|
26
|
+
const resultResponse = await this.dataAccessService.GetDataById(url);
|
|
27
|
+
return resultResponse;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* service for inserting customer data into database
|
|
35
|
+
*
|
|
36
|
+
* @param customerFarmModel
|
|
37
|
+
*
|
|
38
|
+
* @returns Response message from Database
|
|
39
|
+
*/
|
|
40
|
+
public async InsertData(customerFarmModel: CustomerFarmModel) {
|
|
41
|
+
try {
|
|
42
|
+
const url = this.customerFarmApiUrls.insertCustomerFarmDataUrl;
|
|
43
|
+
const resultResponse = await this.dataAccessService.InsertData(url, customerFarmModel);
|
|
44
|
+
return resultResponse;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* service for update customer Data
|
|
52
|
+
*
|
|
53
|
+
* @param customerFarmModel
|
|
54
|
+
*
|
|
55
|
+
* @returns Response message from Database
|
|
56
|
+
*/
|
|
57
|
+
public async UpdateData(customerFarmModel: CustomerFarmModel) {
|
|
58
|
+
try {
|
|
59
|
+
const url = this.customerFarmApiUrls.updateCustomerFarmDataUrl;
|
|
60
|
+
const resultResponse = await this.dataAccessService.UpdateData(url, customerFarmModel);
|
|
61
|
+
return resultResponse;
|
|
62
|
+
} catch (error) {
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* service for delete customer data by GUID
|
|
69
|
+
*
|
|
70
|
+
* @param customerFarmModel
|
|
71
|
+
*
|
|
72
|
+
* @returns Response message from Database
|
|
73
|
+
*/
|
|
74
|
+
public async DeleteData(recordId: any) {
|
|
75
|
+
try {
|
|
76
|
+
const url = this.customerFarmApiUrls.deleteCustomerFarmDataUrl + '/' + recordId;
|
|
77
|
+
const resultResponse = await this.dataAccessService.DeleteData(url);
|
|
78
|
+
return resultResponse;
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* service for get data for customer grid
|
|
87
|
+
*
|
|
88
|
+
* @param customerFarmModel
|
|
89
|
+
*
|
|
90
|
+
* @returns Response Data from Database
|
|
91
|
+
*/
|
|
92
|
+
public async GetListData(customerDataModel: CustomerFarmModel) {
|
|
93
|
+
try {
|
|
94
|
+
const url = this.customerFarmApiUrls.getCustomerFarmListUrl;
|
|
95
|
+
const resultResponse = await this.dataAccessService.GetListData(url, customerDataModel);
|
|
96
|
+
return resultResponse;
|
|
97
|
+
} catch (error) {
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* service for get data for customer DropDown List
|
|
104
|
+
*
|
|
105
|
+
* @returns
|
|
106
|
+
*/
|
|
107
|
+
public async GetCustomersDropdownList() {
|
|
108
|
+
try {
|
|
109
|
+
const url = this.customerFarmApiUrls.getCustomerFarmDropdownListUrl;
|
|
110
|
+
const resultResponse = await this.dataAccessService.GetDropdownListData(url);
|
|
111
|
+
return resultResponse;
|
|
112
|
+
} catch (error) {
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public async GetCustomerListByKeyword(value:string) {
|
|
118
|
+
try {
|
|
119
|
+
const url = this.customerFarmApiUrls.getcustomerlistbykeyword + '/' + value;
|
|
120
|
+
const resultResponse = await this.dataAccessService.GetDataById(url);
|
|
121
|
+
return resultResponse;
|
|
122
|
+
} catch (error) {
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class CustomerFarmApiUrls {
|
|
2
|
+
//api Url string for get data by Id
|
|
3
|
+
getCustomerFarmByIdUrl: string = 'api/CustomerFarm/GetById';
|
|
4
|
+
|
|
5
|
+
//api Url string for insert Customer data
|
|
6
|
+
insertCustomerFarmDataUrl: string = 'api/CustomerFarm/Create';
|
|
7
|
+
|
|
8
|
+
//api Url string for update Customer record
|
|
9
|
+
updateCustomerFarmDataUrl: string = 'api/CustomerFarm/Update';
|
|
10
|
+
|
|
11
|
+
//api Url string for delete Customer record
|
|
12
|
+
deleteCustomerFarmDataUrl: string = 'api/CustomerFarm/Delete';
|
|
13
|
+
|
|
14
|
+
//api Url string for get Customer list
|
|
15
|
+
getCustomerFarmListUrl: string = 'api/CustomerFarm/GetAll';
|
|
16
|
+
|
|
17
|
+
//api Url string for get Customer dropdown list
|
|
18
|
+
getCustomerFarmDropdownListUrl: string = 'api/CustomerFarm/GetDropdownList';
|
|
19
|
+
|
|
20
|
+
//api Url string for get Customer dropdown list
|
|
21
|
+
getcustomerlistbykeyword: string = 'api/CustomerFarm/SearchCustomer';
|
|
22
|
+
}
|