@fleetbase/fleetops-engine
Version:
Fleet & Transport Management Extension for Fleetbase
30 lines (25 loc) • 954 B
JavaScript
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
export default class MaintenanceWorkOrdersIndexEditRoute extends Route {
store;
notifications;
hostRouter;
abilities;
intl;
error(error) {
this.notifications.serverError(error);
if (typeof error.message === 'string' && error.message.endsWith('not found')) {
return this.hostRouter.transitionTo('maintenance.work-orders.index');
}
}
beforeModel() {
if (this.abilities.cannot('fleet-ops update work-order')) {
this.notifications.warning(this.intl.t('common.unauthorized-access'));
return this.hostRouter.transitionTo('maintenance.work-orders.index');
}
}
model({ public_id }) {
return this.store.findRecord('work-order', public_id);
}
}