Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async ngOnInit() {
this.route.params.subscribe(params => {
this.groupName = params.groupName;
});
try {
const data: any = await this.http.get(`/editor/${this.groupName}/content/${this.locationListFileName}`).toPromise();
const flatLocationList = Loc.flatten(data);
// TODO Why do we need zoneLevelLocations???
const zoneLevelLocations = flatLocationList.locations.filter(location => location.level === 'zone');
this.locationsLevels = data.locationsLevels;
this.locationsLevelsLength = data.locationsLevels.length;
await this.setLocationList(data);
} catch (error) {
this.errorHandler.handleError('Could Not Load Location List Data');
}
}
async calculateDescendants() {
// Check if the item being added or moved is at the last level of the hierarchy.
// The descendentsCount needs update ony when the last level has a new item or an item is moved
if (this.locationsLevelsLength === this.breadcrumbs.length) {
this.locationList = Loc.calculateDescendantCounts(this.locationList);
}
}
async saveLocationListToDisk() {
async editItem() {
const flatLocationList = Loc.flatten(this.locationList);
const index = flatLocationList.locations.findIndex(location => location.id === this.form.id);
flatLocationList.locations[index] = { ...flatLocationList.locations[index], ...this.form };
this.locationList = Loc.unflatten(flatLocationList);
await this.setLocationList(this.locationList);
await this.saveLocationListToDisk();
this.isItemMarkedForUpdate = false;
this.hideLocationForm();
}
hideLocationForm() {
generateLocationIDs(locations) {
const flatLocationList = Loc.flatten(locations);
const ID = this.generateID();
const index = flatLocationList.locations.findIndex(location => location.id === ID);
if (index < 0) {
return ID;
} else {
return this.generateLocationIDs(locations);
}
}
return r.rows.map((row) => new TangyFormResponseModel(row.doc))
}
async editItem() {
const flatLocationList = Loc.flatten(this.locationList);
const index = flatLocationList.locations.findIndex(location => location.id === this.form.id);
flatLocationList.locations[index] = { ...flatLocationList.locations[index], ...this.form };
this.locationList = Loc.unflatten(flatLocationList);
await this.setLocationList(this.locationList);
await this.saveLocationListToDisk();
this.isItemMarkedForUpdate = false;
this.hideLocationForm();
}
hideLocationForm() {