Files
iD/modules/osm/qa_item.js
T
Bryan Housel a9a1f945f8 Move the qa_data external
- this means that QAItem now asks the service for the icon rather than knowing it directly
2020-02-07 10:06:47 -05:00

42 lines
957 B
JavaScript

export class QAItem {
constructor(loc, service, itemType, id, props) {
// Store required properties
this.loc = loc;
this.service = service;
this.itemType = itemType;
// All issues must have an ID for selection, use generic if none specified
this.id = id ? id : `${QAItem.id()}`;
this.update(props);
// Some QA services have marker icons to differentiate issues
if (service && typeof service.getIcon === 'function') {
this.icon = service.getIcon(itemType);
}
return this;
}
update(props) {
// You can't override this inital information
const { loc, service, itemType, id } = this;
Object.keys(props).forEach(prop => this[prop] = props[prop]);
this.loc = loc;
this.service = service;
this.itemType = itemType;
this.id = id;
return this;
}
// Generic handling for services without nice IDs
static id() {
return this.nextId--;
}
}
QAItem.nextId = -1;