igniteui-cli 9.0.1 → 9.0.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/migrations/update-4_2_3/index.spec.js +2 -2
- package/package.json +3 -3
- package/templates/webcomponents/igc-ts/custom-templates/subscription-form/files/src/app/__path__/__filePrefix__.ts +61 -0
- package/templates/webcomponents/igc-ts/custom-templates/subscription-form/index.d.ts +1 -0
- package/templates/webcomponents/igc-ts/custom-templates/subscription-form/index.js +18 -0
- package/templates/webcomponents/igc-ts/financial-chart/default/files/src/app/__path__/StockIndexData.ts +130 -0
- package/templates/webcomponents/igc-ts/financial-chart/default/files/src/app/__path__/__filePrefix__.ts +53 -0
- package/templates/webcomponents/igc-ts/financial-chart/default/index.d.ts +1 -0
- package/templates/webcomponents/igc-ts/financial-chart/default/index.js +19 -0
- package/templates/webcomponents/igc-ts/financial-chart/index.d.ts +1 -0
- package/templates/webcomponents/igc-ts/financial-chart/index.js +12 -0
- package/templates/webcomponents/igc-ts/grid/default/files/src/app/__path__/__filePrefix__.ts +4 -7
- package/templates/webcomponents/igc-ts/grid/default/index.js +1 -1
- package/templates/webcomponents/igc-ts/grid/grid-editing/files/src/app/__path__/DataGridSharedData.ts +296 -0
- package/templates/webcomponents/igc-ts/grid/grid-editing/files/src/app/__path__/__filePrefix__.ts +216 -0
- package/templates/webcomponents/igc-ts/grid/grid-editing/index.d.ts +1 -0
- package/templates/webcomponents/igc-ts/grid/grid-editing/index.js +19 -0
- package/templates/webcomponents/igc-ts/grid/grid-summaries/files/src/app/__path__/DataGridSharedData.ts +296 -0
- package/templates/webcomponents/igc-ts/grid/grid-summaries/files/src/app/__path__/__filePrefix__.ts +185 -0
- package/templates/webcomponents/igc-ts/grid/grid-summaries/index.d.ts +1 -0
- package/templates/webcomponents/igc-ts/grid/grid-summaries/index.js +19 -0
- package/templates/webcomponents/igc-ts/grid/index.js +1 -1
- package/templates/webcomponents/igc-ts/groups.json +3 -2
- package/templates/webcomponents/igc-ts/linear-gauge/default/files/src/app/__path__/__filePrefix__.ts +43 -0
- package/templates/webcomponents/igc-ts/linear-gauge/default/index.d.ts +1 -0
- package/templates/webcomponents/igc-ts/linear-gauge/default/index.js +19 -0
- package/templates/webcomponents/igc-ts/linear-gauge/index.d.ts +1 -0
- package/templates/webcomponents/igc-ts/linear-gauge/index.js +12 -0
- package/templates/webcomponents/igc-ts/list/default/index.js +1 -1
- package/templates/webcomponents/igc-ts/list/index.js +1 -1
- package/templates/webcomponents/igc-ts/pie-chart/default/files/src/app/__path__/__filePrefix__.ts +1 -1
- package/templates/webcomponents/igc-ts/projects/empty/files/index.html +0 -1
- package/templates/webcomponents/igc-ts/projects/empty/files/package.json +25 -8
- package/templates/webcomponents/igc-ts/projects/empty/files/src/app/home/home.component.test.ts +1 -1
- package/templates/webcomponents/igc-ts/projects/empty/files/src/app.ts +6 -1
- package/templates/webcomponents/igc-ts/projects/empty/files/src/index.ts +4 -1
- package/templates/webcomponents/igc-ts/projects/empty/files/tsconfig.json +2 -1
- package/templates/webcomponents/igc-ts/projects/empty/files/webpack.config.mjs +67 -0
- package/templates/webcomponents/igc-ts/radial-gauge/default/files/src/app/__path__/__filePrefix__.ts +43 -0
- package/templates/webcomponents/igc-ts/radial-gauge/default/index.d.ts +1 -0
- package/templates/webcomponents/igc-ts/radial-gauge/default/index.js +19 -0
- package/templates/webcomponents/igc-ts/radial-gauge/index.d.ts +1 -0
- package/templates/webcomponents/igc-ts/radial-gauge/index.js +12 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
export class DataGridSharedData {
|
|
2
|
+
public static getEmployees(count?: number): any[] {
|
|
3
|
+
if (count === undefined) {
|
|
4
|
+
count = 250;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const employees: any[] = [];
|
|
8
|
+
let maleCount: number = 0;
|
|
9
|
+
let femaleCount: number = 0;
|
|
10
|
+
for (let i = 0; i < count; i += 1) {
|
|
11
|
+
const age: number = Math.round(this.getRandomNumber(20, 40));
|
|
12
|
+
const gender: string = this.getRandomGender();
|
|
13
|
+
const firstName: string = this.getRandomNameFirst(gender);
|
|
14
|
+
const lastName: string = this.getRandomNameLast();
|
|
15
|
+
const street: string = this.getRandomStreet();
|
|
16
|
+
const country: string = this.getRandomItem(this.countries);
|
|
17
|
+
const city: string = this.getRandomCity(country);
|
|
18
|
+
const generation = `${Math.floor(age / 10) * 10}s`;
|
|
19
|
+
const email: string = `${firstName.toLowerCase()}@${this.getRandomItem(this.emails)}`;
|
|
20
|
+
const website: string = `${firstName.toLowerCase()}-${this.getRandomItem(this.websites)}`;
|
|
21
|
+
let photoPath: any;
|
|
22
|
+
|
|
23
|
+
if (gender === 'male') {
|
|
24
|
+
maleCount += 1;
|
|
25
|
+
if (maleCount > 26) {
|
|
26
|
+
maleCount = 1;
|
|
27
|
+
}
|
|
28
|
+
photoPath = this.getPhotoMale(maleCount);
|
|
29
|
+
} else {
|
|
30
|
+
femaleCount += 1;
|
|
31
|
+
if (femaleCount > 24) {
|
|
32
|
+
femaleCount = 1;
|
|
33
|
+
}
|
|
34
|
+
photoPath = this.getPhotoFemale(femaleCount);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const person: any = {};
|
|
38
|
+
person.Address = `${street},${city}`;
|
|
39
|
+
person.Age = age;
|
|
40
|
+
person.Birthday = this.getBirthday(age);
|
|
41
|
+
person.City = city;
|
|
42
|
+
person.Country = country;
|
|
43
|
+
person.CountryFlag = this.getCountryFlag(country);
|
|
44
|
+
person.Email = email;
|
|
45
|
+
person.FirstName = firstName;
|
|
46
|
+
person.Gender = this.getGenderPhoto(gender);
|
|
47
|
+
person.Generation = generation;
|
|
48
|
+
person.ID = this.pad(i + 1, 5);
|
|
49
|
+
person.LastName = lastName;
|
|
50
|
+
person.Name = `${firstName} ${lastName}`;
|
|
51
|
+
person.Phone = this.getRandomPhone();
|
|
52
|
+
person.Photo = photoPath;
|
|
53
|
+
person.Street = street;
|
|
54
|
+
person.Salary = this.getRandomNumber(40, 200) * 1000;
|
|
55
|
+
person.Sales = this.getRandomNumber(200, 980) * 1000;
|
|
56
|
+
person.Website = website;
|
|
57
|
+
person.Productivity = this.getProductivity();
|
|
58
|
+
|
|
59
|
+
if (person.Salary < 50000) {
|
|
60
|
+
person.Income = 'Low';
|
|
61
|
+
} else if (person.Salary < 100000) {
|
|
62
|
+
person.Income = 'Average';
|
|
63
|
+
} else {
|
|
64
|
+
person.Income = 'High';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
employees.push(person);
|
|
68
|
+
}
|
|
69
|
+
return employees;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public static getProductivity(weekCount?: number): any[] {
|
|
73
|
+
if (weekCount === undefined) {
|
|
74
|
+
weekCount = 52;
|
|
75
|
+
}
|
|
76
|
+
const productivity: any[] = [];
|
|
77
|
+
for (let w = 0; w < weekCount; w += 1) {
|
|
78
|
+
const value = this.getRandomNumber(-50, 50);
|
|
79
|
+
productivity.push({ Value: value, Week: w });
|
|
80
|
+
}
|
|
81
|
+
return productivity;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public static getSales(count?: number): any[] {
|
|
85
|
+
if (count === undefined) {
|
|
86
|
+
count = 250;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const names: string[] = [
|
|
90
|
+
'Intel CPU', 'AMD CPU',
|
|
91
|
+
'NVIDIA GPU', 'GIGABYTE GPU', 'Asus GPU', 'AMD GPU', 'MSI GPU',
|
|
92
|
+
'Corsair Memory', 'Patriot Memory', 'Skill Memory',
|
|
93
|
+
'Samsung HDD', 'WD HDD', 'Seagate HDD', 'Intel HDD',
|
|
94
|
+
'Samsung SSD', 'WD SSD', 'Seagate SSD', 'Intel SSD',
|
|
95
|
+
'Samsung Monitor', 'Asus Monitor', 'LG Monitor', 'HP Monitor'];
|
|
96
|
+
const countries: string[] = ['USA', 'UK', 'France', 'Canada', 'Poland', 'Japan', 'Germany'];
|
|
97
|
+
const status: string[] = ['Packing', 'Shipped', 'Delivered'];
|
|
98
|
+
const sales: any[] = [];
|
|
99
|
+
|
|
100
|
+
for (let i = 0; i < count; i += 1) {
|
|
101
|
+
const price = this.getRandomNumber(100, 900);
|
|
102
|
+
const items = this.getRandomNumber(10, 80);
|
|
103
|
+
const value = price * items;
|
|
104
|
+
const margin = this.getRandomNumber(3, 10);
|
|
105
|
+
const profit = Math.round((price * margin / 100) * items);
|
|
106
|
+
const country = this.getRandomItem(countries);
|
|
107
|
+
sales.push({
|
|
108
|
+
BundlePrice: price,
|
|
109
|
+
ProductPrice: price,
|
|
110
|
+
Margin: margin,
|
|
111
|
+
OrderDate: this.getRandomDate(new Date(2012, 0, 1), new Date()),
|
|
112
|
+
OrderItems: items,
|
|
113
|
+
OrderValue: value, // Math.round(value / 1000) + ',' + Math.round(value % 1000),
|
|
114
|
+
ProductID: 1001 + i,
|
|
115
|
+
ProductName: this.getRandomItem(names),
|
|
116
|
+
Profit: profit,
|
|
117
|
+
Countries: country,
|
|
118
|
+
CountryFlag: this.getCountryFlag(country),
|
|
119
|
+
Status: this.getRandomItem(status),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return sales;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public static getHouses(count?: number): any[] {
|
|
126
|
+
if (count === undefined) {
|
|
127
|
+
count = 250;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const houses: any[] = [];
|
|
131
|
+
const property: string[] = ['Townhouse', 'Single', 'Condo', 'Villa'];
|
|
132
|
+
const emails: string[] = ['estates.com', 'remax.com', 'zillow.com', 'realtor.com', 'coldwell.com'];
|
|
133
|
+
const countries: string[] = ['USA', 'UK', 'France', 'Canada', 'Poland', 'Japan', 'Germany'];
|
|
134
|
+
|
|
135
|
+
for (let i = 0; i < count; i += 1) {
|
|
136
|
+
const year: number = this.getRandomNumber(1950, 2015);
|
|
137
|
+
const age: number = 2020 - year;
|
|
138
|
+
|
|
139
|
+
const gender: string = this.getRandomGender();
|
|
140
|
+
const firstName: string = this.getRandomNameFirst(gender);
|
|
141
|
+
const lastName: string = this.getRandomNameLast();
|
|
142
|
+
const initials = firstName.substr(0, 1).toLowerCase();
|
|
143
|
+
const email: string = `${initials + lastName.toLowerCase()}@${this.getRandomItem(emails)}`;
|
|
144
|
+
|
|
145
|
+
const street: string = this.getRandomStreet();
|
|
146
|
+
const country: string = this.getRandomItem(countries);
|
|
147
|
+
const city: string = this.getRandomCity(country);
|
|
148
|
+
|
|
149
|
+
houses.push({
|
|
150
|
+
Address: `${street},${city}`,
|
|
151
|
+
Age: age,
|
|
152
|
+
Agent: `${firstName} ${lastName}`,
|
|
153
|
+
Area: this.getRandomNumber(50, 300),
|
|
154
|
+
Baths: this.getRandomNumber(1, 3),
|
|
155
|
+
Built: year,
|
|
156
|
+
City: city,
|
|
157
|
+
Country: country,
|
|
158
|
+
CountryFlag: this.getCountryFlag(country),
|
|
159
|
+
Email: email,
|
|
160
|
+
ID: this.pad(i + 1, 5),
|
|
161
|
+
Phone: this.getRandomPhone(),
|
|
162
|
+
Price: this.getRandomNumber(210, 900) * 1000,
|
|
163
|
+
Property: this.getRandomItem(property),
|
|
164
|
+
Rooms: this.getRandomNumber(2, 5),
|
|
165
|
+
SaleDate: this.getRandomDate(new Date(2015, 0, 1), new Date()),
|
|
166
|
+
Street: street,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return houses;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private static websites: string[] = ['.com', '.gov', '.edu', '.org'];
|
|
173
|
+
|
|
174
|
+
private static emails: string[] = ['gmail.com', 'yahoo.com', 'twitter.com'];
|
|
175
|
+
|
|
176
|
+
private static genders: string[] = ['male', 'female'];
|
|
177
|
+
|
|
178
|
+
private static maleNames: string[] = ['Kyle', 'Oscar', 'Ralph', 'Mike', 'Bill', 'Frank', 'Howard', 'Jack', 'Larry', 'Pete', 'Steve', 'Vince', 'Mark', 'Alex', 'Max', 'Brian', 'Chris', 'Andrew', 'Martin', 'Mike', 'Steve', 'Glenn', 'Bruce'];
|
|
179
|
+
|
|
180
|
+
private static femaleNames: string[] = ['Gina', 'Irene', 'Katie', 'Brenda', 'Casey', 'Fiona', 'Holly', 'Kate', 'Liz', 'Pamela', 'Nelly', 'Marisa', 'Monica', 'Anna', 'Jessica', 'Sofia', 'Isabella', 'Margo', 'Jane', 'Audrey', 'Sally', 'Melanie', 'Greta', 'Aurora', 'Sally'];
|
|
181
|
+
|
|
182
|
+
private static lastNames: string[] = ['Adams', 'Crowley', 'Ellis', 'Martinez', 'Irvine', 'Maxwell', 'Clark', 'Owens', 'Rooney', 'Lincoln', 'Thomas', 'Spacey', 'MOrgan', 'King', 'Newton', 'Fitzgerald', 'Holmes', 'Jefferson', 'Landry', 'Berry', 'Perez', 'Spencer', 'Starr', 'Carter', 'Edwards', 'Stark', 'Johnson', 'Fitz', 'Chief', 'Blanc', 'Perry', 'Stone', 'Williams', 'Lane', 'Jobs', 'Adams', 'Power', 'Tesla'];
|
|
183
|
+
|
|
184
|
+
private static countries: string[] = ['USA', 'UK', 'France', 'Canada', 'Poland'];
|
|
185
|
+
|
|
186
|
+
private static citiesUS: string[] = ['New York', 'Los Angeles', 'Miami', 'San Francisco', 'San Diego', 'Las Vegas'];
|
|
187
|
+
|
|
188
|
+
private static citiesUK: string[] = ['London', 'Liverpool', 'Manchester'];
|
|
189
|
+
|
|
190
|
+
private static citiesFR: string[] = ['Paris', 'Marseille', 'Lyon'];
|
|
191
|
+
|
|
192
|
+
private static citiesCA: string[] = ['Toronto', 'Vancouver', 'Montreal'];
|
|
193
|
+
|
|
194
|
+
private static citiesPL: string[] = ['Krakow', 'Warsaw', 'Wroclaw', 'Gdansk'];
|
|
195
|
+
|
|
196
|
+
private static citiesJP: string[] = ['Tokyo', 'Osaka', 'Kyoto', 'Yokohama'];
|
|
197
|
+
|
|
198
|
+
private static citiesGR: string[] = ['Berlin', 'Bonn', 'Cologne', 'Munich', 'Hamburg'];
|
|
199
|
+
|
|
200
|
+
private static roadSuffixes: string[] = ['Road', 'Street', 'Way'];
|
|
201
|
+
|
|
202
|
+
private static roadNames: string[] = ['Main', 'Garden', 'Broad', 'Oak', 'Cedar', 'Park', 'Pine', 'Elm', 'Market', 'Hill'];
|
|
203
|
+
|
|
204
|
+
private static getRandomNumber(min: number, max: number): number {
|
|
205
|
+
return Math.round(min + Math.random() * (max - min));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
private static getRandomItem(array: any[]): any {
|
|
209
|
+
const index = Math.round(this.getRandomNumber(0, array.length - 1));
|
|
210
|
+
return array[index];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
private static getRandomDate(start: Date, end: Date) {
|
|
214
|
+
return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
private static getRandomPhone(): string {
|
|
218
|
+
const phoneCode = this.getRandomNumber(100, 900);
|
|
219
|
+
const phoneNum1 = this.getRandomNumber(100, 900);
|
|
220
|
+
const phoneNum2 = this.getRandomNumber(1000, 9000);
|
|
221
|
+
const phone = `${phoneCode}-${phoneNum1}-${phoneNum2}`;
|
|
222
|
+
return phone;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private static getRandomGender(): string {
|
|
226
|
+
return this.getRandomItem(this.genders);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
private static getRandomNameLast(): string {
|
|
230
|
+
return this.getRandomItem(this.lastNames);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
private static getRandomNameFirst(gender: string): string {
|
|
234
|
+
if (gender === 'male') {
|
|
235
|
+
return this.getRandomItem(this.maleNames);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return this.getRandomItem(this.femaleNames);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
private static getRandomCity(country: string): string {
|
|
242
|
+
if (country === 'Canada') {
|
|
243
|
+
return this.getRandomItem(this.citiesCA);
|
|
244
|
+
} if (country === 'France') {
|
|
245
|
+
return this.getRandomItem(this.citiesFR);
|
|
246
|
+
} if (country === 'Poland') {
|
|
247
|
+
return this.getRandomItem(this.citiesPL);
|
|
248
|
+
} if (country === 'USA') {
|
|
249
|
+
return this.getRandomItem(this.citiesUS);
|
|
250
|
+
} if (country === 'Japan') {
|
|
251
|
+
return this.getRandomItem(this.citiesJP);
|
|
252
|
+
} if (country === 'Germany') {
|
|
253
|
+
return this.getRandomItem(this.citiesGR);
|
|
254
|
+
} // if (country === 'United Kingdom')
|
|
255
|
+
return this.getRandomItem(this.citiesUK);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
private static getRandomStreet(): string {
|
|
259
|
+
const num = Math.round(this.getRandomNumber(100, 300)).toString();
|
|
260
|
+
const road = this.getRandomItem(this.roadNames);
|
|
261
|
+
const suffix = this.getRandomItem(this.roadSuffixes);
|
|
262
|
+
return `${num} ${road} ${suffix}`;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
private static getBirthday(age: number): Date {
|
|
266
|
+
const today: Date = new Date();
|
|
267
|
+
const year: number = today.getFullYear() - age;
|
|
268
|
+
const month: number = this.getRandomNumber(0, 8);
|
|
269
|
+
const day: number = this.getRandomNumber(10, 27);
|
|
270
|
+
return new Date(year, month, day);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
private static getPhotoMale(id: number): string {
|
|
274
|
+
return `https://static.infragistics.com/xplatform/images/people//GUY${this.pad(id, 2)}.png`;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
private static getPhotoFemale(id: number): string {
|
|
278
|
+
return `https://static.infragistics.com/xplatform/images/people/GIRL${this.pad(id, 2)}.png`;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
private static getGenderPhoto(gender: string): string {
|
|
282
|
+
return `https://static.infragistics.com/xplatform/images/genders/${gender}.png`;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
private static getCountryFlag(country: string): string {
|
|
286
|
+
return `https://static.infragistics.com/xplatform/images/flags/${country}.png`;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
private static pad(num: number, size: number) {
|
|
290
|
+
let s = `${num}`;
|
|
291
|
+
while (s.length < size) {
|
|
292
|
+
s = `0${s}`;
|
|
293
|
+
}
|
|
294
|
+
return s;
|
|
295
|
+
}
|
|
296
|
+
}
|
package/templates/webcomponents/igc-ts/grid/grid-editing/files/src/app/__path__/__filePrefix__.ts
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IgcDataGridModule,
|
|
3
|
+
IgcGridColumnOptionsModule,
|
|
4
|
+
IgcDataGridComponent,
|
|
5
|
+
IgcGridCellValueChangingEventArgs,
|
|
6
|
+
IgcTemplateCellUpdatingEventArgs,
|
|
7
|
+
IgcTemplateColumnComponent,
|
|
8
|
+
GridActivationMode,
|
|
9
|
+
GridSelectionMode,
|
|
10
|
+
EditModeType,
|
|
11
|
+
} from 'igniteui-webcomponents-grids';
|
|
12
|
+
import { ModuleManager } from 'igniteui-webcomponents-core';
|
|
13
|
+
import { DataGridSharedData } from './DataGridSharedData';
|
|
14
|
+
|
|
15
|
+
ModuleManager.register(
|
|
16
|
+
IgcDataGridModule,
|
|
17
|
+
IgcGridColumnOptionsModule,
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export default class $(ClassName) extends HTMLElement {
|
|
21
|
+
data: any[] = DataGridSharedData.getEmployees();
|
|
22
|
+
|
|
23
|
+
constructor() {
|
|
24
|
+
super();
|
|
25
|
+
this.attachShadow({ mode: 'open' });
|
|
26
|
+
this.shadowRoot!.innerHTML = `
|
|
27
|
+
<style>
|
|
28
|
+
:host {
|
|
29
|
+
height: 100%;
|
|
30
|
+
margin: 0px;
|
|
31
|
+
padding-left: 275px;
|
|
32
|
+
padding-right: 20px;
|
|
33
|
+
width: calc(100% - 300px);
|
|
34
|
+
}
|
|
35
|
+
</style>
|
|
36
|
+
<div class="container sample">
|
|
37
|
+
<div class="options horizontal">
|
|
38
|
+
<button id="commitClick" disabled="true">Commit</button>
|
|
39
|
+
<button id="undoClick" disabled="true">Undo</button>
|
|
40
|
+
<button id="redoClick" disabled="true">Redo</button>
|
|
41
|
+
<span class="options-label">Edit Mode: </span>
|
|
42
|
+
<select id="editModeDropBox" class="options-label">
|
|
43
|
+
<option>Cell</option>
|
|
44
|
+
<option>CellBatch</option>
|
|
45
|
+
<option>Row</option>
|
|
46
|
+
<option>None</option>
|
|
47
|
+
</select>
|
|
48
|
+
<label id="excel-style-editing" >Excel Style</label>
|
|
49
|
+
<span class="options-label">Edit Mode: </span>
|
|
50
|
+
<select id="editModeClickActionDropBox" class="options-label">
|
|
51
|
+
<option>SingleClick</option>
|
|
52
|
+
<option>DoubleClick</option>
|
|
53
|
+
</select>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<igc-data-grid
|
|
57
|
+
id="grid"
|
|
58
|
+
height="calc(100% - 3.5rem)"
|
|
59
|
+
width="100%"
|
|
60
|
+
activation-mode="Cell"
|
|
61
|
+
selection-mode="SingleCell"
|
|
62
|
+
default-column-min-width="125"
|
|
63
|
+
is-column-options-enabled="true"
|
|
64
|
+
auto-generate-columns="false"
|
|
65
|
+
edit-mode-click-action="SingleClick"
|
|
66
|
+
edit-mode="Cell">
|
|
67
|
+
|
|
68
|
+
<igc-text-column field="Name" width="*>150"></igc-text-column>
|
|
69
|
+
<igc-text-column field="Street" header-text="Street" width="*>155"></igc-text-column>
|
|
70
|
+
<igc-text-column field="City" header-text="City" width="*>125"></igc-text-column>
|
|
71
|
+
<igc-numeric-column field="Salary" header-text="Salary" positive-prefix="$" show-grouping-separator="true"></igc-numeric-column>
|
|
72
|
+
|
|
73
|
+
<igc-image-column field="Photo" header-text="Photo" content-opacity="1"
|
|
74
|
+
horizontal-alignment="center" width="*>90"></igc-image-column>
|
|
75
|
+
<igc-date-time-column field="Birthday" header-text="Date of Birth" width="*>140"></igc-date-time-column>
|
|
76
|
+
<igc-template-column id="deleteRowColumn" field="Delete Row" header-text="Delete Row" width="*>140" is-column-options-enabled="false" ></igc-date-time-column>
|
|
77
|
+
</igc-data-grid>
|
|
78
|
+
</div>
|
|
79
|
+
`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
connectedCallback() {
|
|
83
|
+
const onCommitClick = () => {
|
|
84
|
+
grid.commitEdits();
|
|
85
|
+
commitButton.disabled = true;
|
|
86
|
+
undoButton.disabled = !grid.canUndo;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const onUndoClick = () => {
|
|
90
|
+
grid.undo();
|
|
91
|
+
undoButton.disabled = !grid.canUndo;
|
|
92
|
+
if (!grid.canUndo) {
|
|
93
|
+
commitButton.disabled = grid.canCommit;
|
|
94
|
+
} else {
|
|
95
|
+
commitButton.disabled = !grid.canCommit;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
redoButton.disabled = !grid.canRedo;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const onRedoClick = () => {
|
|
102
|
+
grid.redo();
|
|
103
|
+
|
|
104
|
+
if (grid.editMode === EditModeType.Cell || grid.editMode === EditModeType.None) {
|
|
105
|
+
commitButton.disabled = !grid.canCommit;
|
|
106
|
+
}
|
|
107
|
+
if (grid.editMode === EditModeType.CellBatch || grid.editMode === EditModeType.Row) {
|
|
108
|
+
redoButton.disabled = !grid.canRedo;
|
|
109
|
+
undoButton.disabled = !grid.canUndo;
|
|
110
|
+
if (!grid.canUndo) {
|
|
111
|
+
commitButton.disabled = grid.canCommit;
|
|
112
|
+
} else {
|
|
113
|
+
commitButton.disabled = !grid.canCommit;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const onDeleteCellUpdating = (s: IgcTemplateColumnComponent, e: IgcTemplateCellUpdatingEventArgs) => {
|
|
119
|
+
const content = e.content as HTMLDivElement;
|
|
120
|
+
if (content.childElementCount === 0) {
|
|
121
|
+
const button = document.createElement('button') as HTMLButtonElement;
|
|
122
|
+
button.innerText = 'Delete';
|
|
123
|
+
button.onclick = onDeleteRowClick;
|
|
124
|
+
content.appendChild(button);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const button = content.children[0] as HTMLButtonElement;
|
|
128
|
+
button.disabled = e.cellInfo.isDeleted;
|
|
129
|
+
button.id = e.cellInfo.dataRow.toString();
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const editModeChanged = (event: any) => {
|
|
133
|
+
grid.cancelEdits();
|
|
134
|
+
grid.editMode = event.target.value;
|
|
135
|
+
if (grid.editMode === EditModeType.None || grid.editMode === EditModeType.Cell) {
|
|
136
|
+
commitButton.disabled = true;
|
|
137
|
+
undoButton.disabled = !grid.canUndo;
|
|
138
|
+
redoButton.disabled = !grid.canRedo;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const editModeClickActionChanged = (event: any) => {
|
|
143
|
+
grid.editModeClickAction = event.target.value;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const onDeleteRowClick = (e: MouseEvent) => {
|
|
147
|
+
const button = e.srcElement as HTMLButtonElement;
|
|
148
|
+
const viewIndex = parseInt(button.id);
|
|
149
|
+
const rowItem = grid.actualDataSource.getItemAtIndex(viewIndex);
|
|
150
|
+
|
|
151
|
+
if (grid.editMode === EditModeType.CellBatch || grid.editMode === EditModeType.Row) {
|
|
152
|
+
grid.removeItem(rowItem);
|
|
153
|
+
commitButton.disabled = !grid.canCommit;
|
|
154
|
+
redoButton.disabled = !grid.canRedo;
|
|
155
|
+
undoButton.disabled = !grid.canUndo;
|
|
156
|
+
} else if (grid.editMode === EditModeType.Cell) {
|
|
157
|
+
//delete grid row immediately
|
|
158
|
+
grid.removeItem(rowItem);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const onCellValueChanging = (s: IgcDataGridComponent, e: IgcGridCellValueChangingEventArgs) => {
|
|
163
|
+
if (s.editMode === EditModeType.CellBatch || grid.editMode === EditModeType.Row) {
|
|
164
|
+
commitButton.disabled = !grid.canCommit;
|
|
165
|
+
undoButton.disabled = false;
|
|
166
|
+
} else if (grid.editMode === EditModeType.Cell || grid.editMode === EditModeType.None) {
|
|
167
|
+
commitButton.disabled = grid.canCommit;
|
|
168
|
+
}
|
|
169
|
+
if (e.newValue === '') {
|
|
170
|
+
commitButton.disabled = true;
|
|
171
|
+
s.setEditError(e.editID, 'Error, cell is empty');
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const grid = document.getElementsByTagName('app-$(path)')[0].shadowRoot!.getElementById('grid') as IgcDataGridComponent;
|
|
176
|
+
if (grid !== null) {
|
|
177
|
+
grid.dataSource = this.data;
|
|
178
|
+
grid.activationMode = GridActivationMode.Cell;
|
|
179
|
+
grid.selectionMode = GridSelectionMode.SingleCell;
|
|
180
|
+
grid.editMode = EditModeType.Cell;
|
|
181
|
+
grid.cellValueChanging = onCellValueChanging;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const dropDown = document.getElementsByTagName('app-$(path)')[0].shadowRoot!.getElementById('editModeDropBox');
|
|
185
|
+
if (dropDown !== null) {
|
|
186
|
+
dropDown.onchange = editModeChanged;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const dropDown2 = document.getElementsByTagName('app-$(path)')[0].shadowRoot!.getElementById('editModeClickActionDropBox');
|
|
190
|
+
if (dropDown2 !== null) {
|
|
191
|
+
dropDown2.onchange = editModeClickActionChanged;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
let commitButton = document.getElementsByTagName('app-$(path)')[0].shadowRoot!.getElementById('commitClick') as HTMLButtonElement;
|
|
195
|
+
if (commitButton !== null) {
|
|
196
|
+
commitButton.onclick = onCommitClick;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
let undoButton = document.getElementsByTagName('app-$(path)')[0].shadowRoot!.getElementById('undoClick') as HTMLButtonElement;
|
|
200
|
+
if (undoButton !== null) {
|
|
201
|
+
undoButton.onclick = onUndoClick;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
let redoButton = document.getElementsByTagName('app-$(path)')[0].shadowRoot!.getElementById('redoClick') as HTMLButtonElement;
|
|
205
|
+
if (redoButton !== null) {
|
|
206
|
+
redoButton.onclick = onRedoClick;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const deleteRowColumn = document.getElementsByTagName('app-$(path)')[0].shadowRoot!.getElementById('deleteRowColumn') as IgcTemplateColumnComponent;
|
|
210
|
+
if (deleteRowColumn !== null) {
|
|
211
|
+
deleteRowColumn.cellUpdating = onDeleteCellUpdating;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
customElements.define('app-$(path)', $(ClassName));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const IgniteUIForWebComponentsTemplate_1 = require("../../../../../lib/templates/IgniteUIForWebComponentsTemplate");
|
|
4
|
+
class IgcGridEditingTemplate extends IgniteUIForWebComponentsTemplate_1.IgniteUIForWebComponentsTemplate {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(__dirname);
|
|
7
|
+
this.components = ["Grid"];
|
|
8
|
+
this.controlGroup = "Grids & Lists";
|
|
9
|
+
this.listInComponentTemplates = true;
|
|
10
|
+
this.id = "grid-editing";
|
|
11
|
+
this.projectType = "igc-ts";
|
|
12
|
+
this.name = "Grid Editing";
|
|
13
|
+
this.description = "IgcGrid with editing enabled";
|
|
14
|
+
}
|
|
15
|
+
addClassDeclaration(mainModule, projPath, name, modulePath) {
|
|
16
|
+
// not applicable with custom module
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
module.exports = new IgcGridEditingTemplate();
|