Change the first character of all end-of-line comments to upper case
This commit is contained in:
@ -16,7 +16,7 @@ export class DataService {
|
||||
private api: ApiService
|
||||
) { }
|
||||
|
||||
private collectionMap = { // list of available collections
|
||||
private collectionMap = { // List of available collections
|
||||
materials: {path: '/materials?status[]=validated&status[]=new', model: MaterialModel, type: 'idArray'},
|
||||
materialSuppliers: {path: '/material/suppliers', model: null, type: 'idArray'},
|
||||
materialGroups: {path: '/material/groups', model: null, type: 'idArray'},
|
||||
@ -31,31 +31,31 @@ export class DataService {
|
||||
userKey: {path: '/user/key', model: BaseModel, type: 'string'}
|
||||
};
|
||||
|
||||
arr: {[key: string]: any[]} = {}; // array of data
|
||||
latest: {[key: string]: any[]} = {}; // array of latest template versions
|
||||
id: {[key: string]: {[id: string]: any}} = {}; // data in format _id: data
|
||||
d: {[key: string]: any} = {}; // data not in array format
|
||||
arr: {[key: string]: any[]} = {}; // Array of data
|
||||
latest: {[key: string]: any[]} = {}; // Array of latest template versions
|
||||
id: {[key: string]: {[id: string]: any}} = {}; // Data in format _id: data
|
||||
d: {[key: string]: any} = {}; // Data not in array format
|
||||
|
||||
contact = {name: 'CR/APS1-Lingenfelser', mail: 'dominic.lingenfelser@bosch.com'}; // global contact data
|
||||
contact = {name: 'CR/APS1-Lingenfelser', mail: 'dominic.lingenfelser@bosch.com'}; // Global contact data
|
||||
|
||||
load(collection, f = () => {}) { // load data
|
||||
if (this.arr[collection]) { // data already loaded
|
||||
load(collection, f = () => {}) { // Load data
|
||||
if (this.arr[collection]) { // Data already loaded
|
||||
f();
|
||||
}
|
||||
else { // load data
|
||||
else { // Load data
|
||||
this.api.get<any>(this.collectionMap[collection].path, data => {
|
||||
if (this.collectionMap[collection].type !== 'string') { // array data
|
||||
if (this.collectionMap[collection].type !== 'string') { // Array data
|
||||
this.arr[collection] = data
|
||||
.map(
|
||||
e => this.collectionMap[collection].model ?
|
||||
new this.collectionMap[collection].model().deserialize(e) : e
|
||||
);
|
||||
// load ids
|
||||
// Load ids
|
||||
if (this.collectionMap[collection].type === 'idArray' || this.collectionMap[collection].type === 'template') {
|
||||
this.idReload(collection);
|
||||
}
|
||||
}
|
||||
else { // not array data
|
||||
else { // Not array data
|
||||
this.d[collection] = new this.collectionMap[collection].model().deserialize(data);
|
||||
}
|
||||
f();
|
||||
@ -63,13 +63,13 @@ export class DataService {
|
||||
}
|
||||
}
|
||||
|
||||
// generate id object
|
||||
// Generate id object
|
||||
idReload(collection) {
|
||||
this.id[collection] = this.arr[collection].reduce((s, e) => {s[e._id] = e; return s; }, {});
|
||||
if (this.collectionMap[collection].type === 'template') { // generate array with latest templates
|
||||
if (this.collectionMap[collection].type === 'template') { // Generate array with latest templates
|
||||
const tmpTemplates = {};
|
||||
this.arr[collection].forEach(template => {
|
||||
if (tmpTemplates[template.first_id]) { // already found another version
|
||||
if (tmpTemplates[template.first_id]) { // Already found another version
|
||||
if (template.version > tmpTemplates[template.first_id].version) {
|
||||
tmpTemplates[template.first_id] = template;
|
||||
}
|
||||
|
Reference in New Issue
Block a user