Skip to content

Commit

Permalink
Asset enhancement work.
Browse files Browse the repository at this point in the history
- Added an order number column to track the vendor's order number a radio belongs to.
- Allow expired assets to be forced checked out because the playa always throws a curveball every event.
- Indicate if an asset was forced checked out on some reports and table listings.
- Added mobile/vehicle radios, desktop radios, and radio charge asset types.
- Let the user know assets with entity assignments cannot be checked out.
- Renamed asset assignment (event vs shift) columns to duration.
  • Loading branch information
mikeburg committed Jan 12, 2025
1 parent 6e326fd commit 2a86d01
Show file tree
Hide file tree
Showing 19 changed files with 379 additions and 181 deletions.
11 changes: 9 additions & 2 deletions app/components/asset-checkout-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,18 @@
<ModalDialog @onEscape={{this.closeExpiredDialog}} as |Modal|>
<Modal.title>Asset Has Expired</Modal.title>
<Modal.body>
Asset {{this.assetExpired.barcode}} has expired and should not be handed out. Please place it
in the designated pile for return to the vendor.
<p>
Asset #{{this.assetExpired.barcode}} is no longer eligible for checkout and should not be handed out.
Place it in the designated pile for return to the vendor.
</p>
The checkout can be forced if you have authorization from the HQ Lead due to unforeseen circumstances. The
action will be logged and subject to review.
</Modal.body>
<Modal.footer>
<UiCloseButton @onClick={{this.closeExpiredDialog}} />
<UiButton @onClick={{this.forceCheckout}} @type="warning">
Force Checkout
</UiButton>
</Modal.footer>
</ModalDialog>
{{else}}
Expand Down
37 changes: 30 additions & 7 deletions app/components/asset-checkout-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class AssetCheckoutFormComponent extends Component {
@service modal;
@service toast;

@tracked assetForm = EmberObject.create({barcode:''});
@tracked assetForm = EmberObject.create({barcode: ''});

@tracked barcodeNotFound = null;
@tracked barcodeCheckedOut = null;
Expand Down Expand Up @@ -46,20 +46,26 @@ export default class AssetCheckoutFormComponent extends Component {
*/

@action
async checkoutAsset(model) {
checkoutAsset(model) {
const {barcode} = model;
this.clearErrors();

if (barcode.trim() === '') {
this.modal.info(null, 'No barcode number was enterd.');
this.modal.info(null, 'No barcode number was entered.');
return;
}

this._performCheckout(model.barcode, model.attachment_id);
}

async _performCheckout(barcode, attachment_id, force = false) {
this.isSubmitting = true;
try {
const result = await this.ajax.request('asset/checkout', {
method: 'POST',
data: {person_id: this.args.person.id, barcode, attachment_id: model.attachment_id}
});
const data = {person_id: this.args.person.id, barcode, attachment_id};
if (force) {
data.force = 1;
}
const result = await this.ajax.post('asset/checkout', {data});

switch (result.status) {
case 'success':
Expand All @@ -79,6 +85,17 @@ export default class AssetCheckoutFormComponent extends Component {
break;
case 'expired':
this.assetExpired = result;
this.forceBarcode = barcode;
this.forceAttachmentId = attachment_id;
break;

case 'entity-assigned':
this.modal.info('Asset Is Assigned', `Asset #${barcode} cannot be checked out because it has been assigned to ${result.entity}. Asset assignments differ from asset checkouts because assignments are for situations where the person does not have a Clubhouse account, such as Burn Perimeter Support or High Rock Security members, or where the asset is used by a team or service rather than an individual.`);
break;

default:
this.modal.info('Unknown Status', `A bug was tripped over. The status ${result.status} is not known.`);
break;
}
} catch (response) {
this.house.handleErrorResponse(response)
Expand All @@ -87,6 +104,12 @@ export default class AssetCheckoutFormComponent extends Component {
}
}

@action
forceCheckout() {
this.assetExpired = null;
this._performCheckout(this.forceBarcode, this.forceAttachmentId, true);
}

/**
* Show the asset history for a checked out asset.
*/
Expand Down
13 changes: 13 additions & 0 deletions app/components/asset-duration-label.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{#if (eq @asset.type "radio")}}
{{#if @asset.perm_assign}}
<UiBadge @text="event" @type="gray"/>
{{else}}
<UiBadge @text="shift" @type="warning"/>
{{/if}}
{{else}}
{{#if @asset.perm_assign}}
<UiBadge @text="permanent" @type="gray"/>
{{else}}
<UiBadge @text="temporary" @type="warning"/>
{{/if}}
{{/if}}
10 changes: 8 additions & 2 deletions app/components/asset-table.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
<th>Type</th>
<th>Barcode</th>
<th>Attachment</th>
<th>Assigned</th>
<th>Duration</th>
<th>Description</th>
<th>Checked Out Time /<br>By Person</th>
<th>Checked In Time /<br>By Person</th>
<th>Time (HH:SS)</th>
<th>Action</th>
</tr>
</thead>
Expand All @@ -20,7 +21,9 @@
<td>
<PresentOrNot @value={{ap.attachment.description}} @empty="-"/>
</td>
<td>{{if ap.asset.perm_assign "Perm" "Temp"}}</td>
<td class="text-center">
<AssetDurationLabel @asset={{ap.asset}}/>
</td>
<td>
<PresentOrNot @value={{ap.asset.description}} @empty="-"/>
</td>
Expand Down Expand Up @@ -49,6 +52,9 @@
{{/if}}
{{/if}}
</td>
<td class="text-end">
{{hour-minute-format ap.duration}}
</td>
<td>
<UiButton @type="secondary" @size="sm" @onClick={{fn this.showHistoryAction ap.asset}}>
History
Expand Down
22 changes: 7 additions & 15 deletions app/components/hq-asset-table.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<th>Type</th>
<th>Barcode</th>
<th>Attachment</th>
<th>Description</th>
<th>Description / Group</th>
<th>Checked Out</th>
<th>Actions</th>
<th class="w-5">&nbsp;</th>
Expand All @@ -13,7 +13,10 @@
<tbody>
{{#each @assetsCheckedOut as |ap|}}
<tr>
<td>{{this.typeLabel ap.asset.type}}</td>
<td>
{{this.typeLabel ap.asset.type}}
<AssetDurationLabel @asset={{ap.asset}} />
</td>
<td>{{ap.asset.barcode}}</td>
<td>
<PresentOrNot @value={{ap.attachment.description}} @empty="none"/>
Expand All @@ -26,19 +29,8 @@
<td>
<PresentOrNot @value={{ap.asset.description}} @empty="-"/>
<br>
{{#if (eq ap.asset.type "radio")}}
{{#if ap.asset.perm_assign}}
<UiBadge @text="Event Radio" @type="gray" />
{{else}}
<UiBadge @text="Shift Radio" @type="warning" />
{{/if}}
{{else}}
{{#if ap.asset.perm_assign}}
<UiBadge @text="Permanent" @type="gray" />
{{else}}
<UiBadge @text="Temporary" @type="warning" />
{{/if}}
{{/if}}
<PresentOrNot @value={{ap.asset.group_name}} @empty="-"/>
<br>
</td>
<td>{{shift-format ap.checked_out}}</td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion app/components/ui-table.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<table class="table {{unless @noWidthAuto "table-width-auto"}} {{unless @normalSize "table-sm"}} table-hover {{unless @noStriped "table-striped"}}" ...attributes>
<table class="table {{unless @noWidthAuto "table-width-auto"}} {{unless @normalSize "table-sm"}} table-hover {{unless @noStriped "table-striped"}} {{if @stickyHeader "table-sticky"}}" ...attributes>
{{yield}}
</table>
Loading

0 comments on commit 2a86d01

Please sign in to comment.