Skip to content
This repository has been archived by the owner on Mar 4, 2022. It is now read-only.

Commit

Permalink
Fix #19 and update appearance (#29)
Browse files Browse the repository at this point in the history
* Add slug to input

* Change how the status appears

Co-authored-by: Sean Meyer <[email protected]>
  • Loading branch information
slinkymanbyday and Sean Meyer authored Dec 22, 2020
1 parent 3d0f815 commit 6a9b7f1
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/aftership-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ export class AftershipCard extends LitElement {
${item.name}
</div>
<div class="secondary">
${item.tracking_number} (${item.slug})
${item.last_checkpoint && item.last_checkpoint.message ? item.last_checkpoint.message : ''}
(${item.status})
</div>
</paper-item-body>
<paper-item-body class="last">
Expand Down Expand Up @@ -179,6 +180,15 @@ export class AftershipCard extends LitElement {
required
></paper-input>
</paper-item-body>
<paper-item-body>
<paper-input
no-label-float
placeholder="Slug"
@keydown=${this._addKeyPress}
id="slug"
required
></paper-input>
</paper-item-body>
</paper-item>
`}
</ha-card>
Expand Down Expand Up @@ -206,21 +216,32 @@ export class AftershipCard extends LitElement {

return null;
}
private get _slug(): HTMLElement | null {
if (this.shadowRoot) {
return this.shadowRoot.querySelector('#slug');
}

return null;
}

private _addItem(ev): void {
/* eslint-disable @typescript-eslint/no-explicit-any */
const title = this._title as any;
/* eslint-disable @typescript-eslint/no-explicit-any */
const tracking = this._tracking as any;
/* eslint-disable @typescript-eslint/no-explicit-any */
const slug = this._slug as any;

if (this.hass && title && tracking && tracking.value && tracking.value.length > 0) {
this.hass.callService('aftership', 'add_tracking', {
tracking_number: tracking.value,
title: title.value,
slug: slug.value,
});

title.value = '';
tracking.value = '';
slug.value = '';

if (ev) {
title.focus();
Expand Down

0 comments on commit 6a9b7f1

Please sign in to comment.