Skip to content

Commit 551a429

Browse files
authored
Merge pull request #79 from fleetbase/dev-v0.2.38
patch disabled button/dropdown-button patch coordinates input component
2 parents eab5966 + 857d05b commit 551a429

File tree

8 files changed

+45
-15
lines changed

8 files changed

+45
-15
lines changed

addon/components/button.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{#if this.visible}}
2-
<span class="btn-wrapper {{@wrapperClass}} inline-flex rounded-md {{if this.isNotSecondary 'shadow-sm'}} {{if @isLoading 'is-loading'}}" {{did-insert this.setupComponent}}>
2+
<span class="btn-wrapper {{@wrapperClass}} inline-flex rounded-md {{if this.isNotSecondary 'shadow-sm'}} {{if @isLoading 'is-loading'}}" {{did-insert this.setupComponent}} {{did-update this.onArgsChanged @disabled @visible @permission}}>
33
<button
44
class="btn {{if @isLoading 'btn-is-loading'}} {{if @outline 'btn-outline'}} btn-{{or @type 'default'}} btn-{{or @size 'sm'}}"
55
disabled={{this.isDisabled}}

addon/components/button.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ export default class ButtonComponent extends Component {
6969
*/
7070
@tracked visible = true;
7171

72+
/**
73+
* Determines if the button is disabled
74+
*
75+
* @memberof ButtonComponent
76+
*/
77+
@tracked disabled = false;
78+
7279
/**
7380
* Creates an instance of ButtonComponent.
7481
* @param {*} owner
@@ -79,7 +86,7 @@ export default class ButtonComponent extends Component {
7986
super(...arguments);
8087
this.permissionRequired = permission;
8188
this.visible = visible;
82-
if (!disabled) {
89+
if (!disabled && permission) {
8390
this.disabledByPermission = permission && this.abilities.cannot(permission);
8491
}
8592
}
@@ -114,4 +121,12 @@ export default class ButtonComponent extends Component {
114121
onClick(...arguments);
115122
}
116123
}
124+
125+
@action onArgsChanged(el, [disabled = false, visible = true, permission = null]) {
126+
this.permissionRequired = permission;
127+
this.visible = visible;
128+
if (!disabled && permission) {
129+
this.disabledByPermission = permission && this.abilities.cannot(permission);
130+
}
131+
}
117132
}

addon/components/chat-window.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,16 +214,20 @@ export default class ChatWindowComponent extends Component {
214214
}
215215

216216
@task *loadAvailableUsers(params = {}) {
217-
const users = yield this.store.query('user', params);
218-
const availableUsers = users.filter((user) => {
219-
const isNotSender = user.id !== this.sender.user_uuid;
220-
const isNotParticipant = !this.getParticipantByUserId(user.id);
217+
try {
218+
const users = yield this.store.query('user', params);
219+
const availableUsers = users.filter((user) => {
220+
const isNotSender = user.id !== this.sender.user_uuid;
221+
const isNotParticipant = !this.getParticipantByUserId(user.id);
221222

222-
return isNotSender && isNotParticipant;
223-
});
223+
return isNotSender && isNotParticipant;
224+
});
224225

225-
this.availableUsers = availableUsers;
226-
return availableUsers;
226+
this.availableUsers = availableUsers;
227+
return availableUsers;
228+
} catch (err) {
229+
console.warn('Error loading available users:', err);
230+
}
227231
}
228232

229233
handleChatFeedScroll() {

addon/components/coordinates-input.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<div class="flex flex-col">
4444
<div class="flex flex-row items-center pb-4">
4545
<Input @type="text" class="form-input mr-2" @value={{this.lookupQuery}} aria-label="Address Search" disabled={{or this.disabled this.reverseLookup.isRunning}} placeholder="Enter address" />
46-
<Button @wrapperClass="mr-2" @icon="search-location" @type="primary" @size="sm" @text="Lookup" @onClick={{perofrm this.reverseLookup}} @isLoading={{this.reverseLookup.isRunning}} />
46+
<Button @wrapperClass="mr-2" @icon="search-location" @type="primary" @size="sm" @text="Lookup" @onClick={{perform this.reverseLookup}} @isLoading={{this.reverseLookup.isRunning}} />
4747
<Button @type="default" @iconPrefix="fas" @icon="times" @size="sm" @text="Done" @onClick={{dd.actions.close}} />
4848
</div>
4949
</div>

addon/components/dropdown-button.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
{{did-insert this.onInsert}}
1616
as |dd|
1717
>
18-
<dd.Trigger class={{@triggerClass}} {{did-insert this.onTriggerInsert}}>
18+
<dd.Trigger class={{@triggerClass}} {{did-insert this.onTriggerInsert}} {{did-update this.onArgsChanged @disabled @visible @permission}}>
1919
{{#if @buttonComponent}}
2020
{{component
2121
@buttonComponent
@@ -44,7 +44,7 @@
4444
@active={{@active}}
4545
@size={{this.buttonSize}}
4646
@isLoading={{@isLoading}}
47-
disabled={{this.disabled}}
47+
@disabled={{this.disabled}}
4848
{{did-insert this.onButtonInsert}}
4949
...attributes
5050
>

addon/components/dropdown-button.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default class DropdownButtonComponent extends Component {
3232
this.disabled = disabled;
3333
this.visible = visible;
3434
// If no permissions disable
35-
if (!disabled) {
35+
if (!disabled && permission) {
3636
this.disabled = this.doesntHavePermissions = permission && this.abilities.cannot(permission);
3737
}
3838
}
@@ -71,4 +71,12 @@ export default class DropdownButtonComponent extends Component {
7171

7272
this._onInsertFired = true;
7373
}
74+
75+
@action onArgsChanged(el, [disabled = false, visible = true, permission = null]) {
76+
this.visible = visible;
77+
this.disabled = disabled;
78+
if (!disabled && permission) {
79+
this.disabled = this.doesntHavePermissions = permission && this.abilities.cannot(permission);
80+
}
81+
}
7482
}

addon/utils/smart-humanize.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ export default function smartHumanize(string) {
3232
'ddp',
3333
'fob',
3434
'gsm',
35+
'etd',
36+
'eta',
37+
'ect',
3538
];
3639

3740
return humanize([decamelize(string)])

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@fleetbase/ember-ui",
3-
"version": "0.2.37",
3+
"version": "0.2.38",
44
"description": "Fleetbase UI provides all the interface components, helpers, services and utilities for building a Fleetbase extension into the Console.",
55
"keywords": [
66
"fleetbase-ui",

0 commit comments

Comments
 (0)