UNPKG

@ducna01120/fleetops-engine

Version:

Fleet & Transport Management Extension for Fleetbase

43 lines (37 loc) 1.36 kB
import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; import { action, set } from '@ember/object'; import isNestedRouteTransition from '@fleetbase/ember-core/utils/is-nested-route-transition'; export default class OperationsServiceRatesIndexRoute extends Route { @service store; @service notifications; @service hostRouter; @service abilities; @service intl; queryParams = { page: { refreshModel: true }, limit: { refreshModel: true }, sort: { refreshModel: true }, query: { refreshModel: true }, service_area: { refreshModel: true }, zone: { refreshModel: true }, }; @action willTransition(transition) { if (isNestedRouteTransition(transition)) { set(this.queryParams, 'page.refreshModel', false); set(this.queryParams, 'sort.refreshModel', false); } } beforeModel() { if (this.abilities.cannot('fleet-ops list service-rate')) { this.notifications.warning(this.intl.t('common.unauthorized-access')); return this.hostRouter.transitionTo('console.fleet-ops'); } } model(params) { return this.store.query('service-rate', { ...params, with: ['parcelFees', 'rateFees', 'zone', 'serviceArea'], }); } }