Skip to content

Commit

Permalink
Merge pull request #1499 from appknox/PD-1612-fix-ember-template-lint…
Browse files Browse the repository at this point in the history
…-errors

upgrade and fix ember-template-lint issues
  • Loading branch information
future-pirate-king authored Dec 27, 2024
2 parents 0ab70f2 + 2b6703f commit fb6c306
Show file tree
Hide file tree
Showing 37 changed files with 2,591 additions and 5,143 deletions.
8 changes: 7 additions & 1 deletion .template-lintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@

module.exports = {
extends: 'recommended',
rules: { 'no-curly-component-invocation': { allow: ['day-js'] } },
rules: {
'no-curly-component-invocation': { allow: ['day-js'] },
// TODO: Remove these rules later on
'no-at-ember-render-modifiers': 'off',
'no-builtin-form-components': 'off',
'no-autofocus-attribute': 'off',
},
};
67 changes: 34 additions & 33 deletions app/components/ak-accordion/index.stories.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { action } from '@ember/object';
import { hbs } from 'ember-cli-htmlbars';

export default {
Expand Down Expand Up @@ -32,6 +33,14 @@ const accordionList = [
},
];

function handleChange() {
this.set('accordionExpanded', !this.accordionExpanded);
}

function handleChangeId(id) {
this.set(id, !this[id]);
}

const Template = (args) => ({
template: hbs`
<AkStack @direction="column" @spacing="3" @width="full" class="mt-3">
Expand All @@ -40,14 +49,14 @@ const Template = (args) => ({
<AkAccordion
@isExpanded={{this.accordionExpanded}}
@onChange={{action this.handleChange}}
@onChange={{this.handleChange}}
@summaryText={{this.summaryText}}
@summaryIconName={{this.summaryIconName}}
@disabled={{this.disabled}}
@variant={{this.accordionVariant}}
>
<:content>
<div class="p-3 m-2" style="color: #ffffff; background-color: #424651;" >
<div class="p-3 m-2" {{style color='#ffffff' backgroundColor='#424651'}} >
<AkTypography @variant="subtitle1" @color="inherit">This is an accordion content</AkTypography>
</div>
</:content>
Expand All @@ -69,7 +78,7 @@ const Template = (args) => ({
@variant={{accordion.accordionVariant}}
>
<:content>
<div class="p-3 m-2" style="color: #ffffff; background-color: #424651;" >
<div class="p-3 m-2" {{style color='#ffffff' backgroundColor='#424651'}} >
<AkTypography @variant="subtitle1" @color="inherit">This is an accordion content</AkTypography>
</div>
</:content>
Expand All @@ -90,9 +99,7 @@ Default.args = {
summaryIconName: 'account-box',
accordionVariant: 'secondary',
accordionExpanded: false,
handleChange() {
this.set('accordionExpanded', !this.accordionExpanded);
},
handleChange: action(handleChange),
};

const WithIconTemplate = (args) => ({
Expand All @@ -101,13 +108,13 @@ const WithIconTemplate = (args) => ({
<AkAccordion
@id="withIcon1"
@isExpanded={{this.withIcon1}}
@onChange={{action this.handleChange}}
@onChange={{this.handleChange}}
@summaryText="Secondary - Summary text with Icon"
@variant="secondary"
@summaryIconName="people"
>
<:content>
<div class="p-3 m-2" style="color: #ffffff; background-color: #424651;" >
<div class="p-3 m-2" {{style color='#ffffff' backgroundColor='#424651'}} >
<AkTypography @variant="subtitle1" @color="inherit">This is an accordion content</AkTypography>
</div>
</:content>
Expand All @@ -116,13 +123,13 @@ const WithIconTemplate = (args) => ({
<AkAccordion
@id="withIcon2"
@isExpanded={{this.withIcon2}}
@onChange={{action this.handleChange}}
@onChange={{this.handleChange}}
@summaryText="Primary - Summary text with Icon"
@variant="primary"
@summaryIconName="people"
>
<:content>
<div class="p-3 m-2" style="color: #ffffff; background-color: #424651;" >
<div class="p-3 m-2" {{style color='#ffffff' backgroundColor='#424651'}} >
<AkTypography @variant="subtitle1" @color="inherit">This is an accordion content</AkTypography>
</div>
</:content>
Expand All @@ -131,14 +138,14 @@ const WithIconTemplate = (args) => ({
<AkAccordion
@id="withIcon3"
@isExpanded={{this.withIcon3}}
@onChange={{action this.handleChange}}
@onChange={{this.handleChange}}
@disabled={{true}}
@summaryText="Disabled - Summary text with Icon"
@variant="secondary"
@summaryIconName="people"
>
<:content>
<div class="p-3 m-2" style="color: #ffffff; background-color: #424651;" >
<div class="p-3 m-2" {{style color='#ffffff' backgroundColor='#424651'}} >
<AkTypography @variant="subtitle1" @color="inherit">This is an accordion content</AkTypography>
</div>
</:content>
Expand All @@ -150,9 +157,7 @@ const WithIconTemplate = (args) => ({
withIcon1: false,
withIcon2: false,
withIcon3: false,
handleChange(id) {
this.set(id, !this[id]);
},
handleChange: action(handleChangeId),
},
});

Expand All @@ -168,7 +173,7 @@ const CustomTemplate = (args) => ({
<AkAccordion
@id="withIcon1"
@isExpanded={{this.withIcon1}}
@onChange={{action this.handleChange}}
@onChange={{this.handleChange}}
>
<:summary as |acs|>
<AkStack @justifyContent="space-between" @alignItems="center" @width="full" class="p-2" {{style border="1px solid #2db421" cursor="pointer"}} {{on 'click' acs.onSummaryClick}}>
Expand All @@ -184,7 +189,7 @@ const CustomTemplate = (args) => ({
</:summary>
<:content>
<div class="p-3 m-2" style="color: #424651; background-color: #fafafa;" >
<div class="p-3 m-2" {{style color='#424651' backgroundColor='#fafafa'}} >
<AkTypography @variant="body1" @gutterBottom={{true}} @color="inherit">- To customize the entire summary bar use the <span class="bold">:summary</span> block. </AkTypography>
<AkTypography @variant="body1" @color="inherit">- The API needed to function was exposed to this block.</AkTypography>
</div>
Expand All @@ -200,7 +205,7 @@ const CustomTemplate = (args) => ({
<AkAccordion
@id="withIcon2"
@isExpanded={{this.withIcon2}}
@onChange={{action this.handleChange}}
@onChange={{this.handleChange}}
@variant="primary"
@summaryText="Secondary Variant with custom icon."
>
Expand All @@ -212,7 +217,7 @@ const CustomTemplate = (args) => ({
</:summaryIcon>
<:content>
<div class="p-3 m-2" style="color: #424651; background-color: #fafafa;" >
<div class="p-3 m-2" {{style color='#424651' backgroundColor='#fafafa'}} >
<AkTypography @variant="body1" @gutterBottom={{true}} @color="inherit">- To customize the summary icon only use the <span class="bold">:summaryIcon</span> block. </AkTypography>
</div>
</:content>
Expand All @@ -227,7 +232,7 @@ const CustomTemplate = (args) => ({
<AkAccordion
@id="withIcon3"
@isExpanded={{this.withIcon3}}
@onChange={{action this.handleChange}}
@onChange={{this.handleChange}}
@variant="primary"
@summaryIconName="people"
>
Expand All @@ -238,7 +243,7 @@ const CustomTemplate = (args) => ({
</:summaryText>
<:content>
<div class="p-3 m-2" style="color: #424651; background-color: #fafafa;" >
<div class="p-3 m-2" {{style color='#424651' backgroundColor='#fafafa'}} >
<AkTypography @variant="body1" @gutterBottom={{true}} @color="inherit">- To customize the summary text only use the <span class="bold">:summaryText</span> block. </AkTypography>
</div>
</:content>
Expand All @@ -251,9 +256,7 @@ const CustomTemplate = (args) => ({
withIcon1: false,
withIcon2: false,
withIcon3: false,
handleChange(id) {
this.set(id, !this[id]);
},
handleChange: action(handleChangeId),
},
});

Expand All @@ -275,7 +278,7 @@ const GroupsTemplate = (args) => ({
@variant={{accordion.accordionVariant}}
>
<:content>
<div class="p-3 m-2" style="color: #ffffff; background-color: #424651;" >
<div class="p-3 m-2" {{style color='#ffffff' backgroundColor='#424651'}} >
<AkTypography @variant="subtitle1" @color="inherit">This is an accordion content</AkTypography>
</div>
</:content>
Expand All @@ -297,7 +300,7 @@ const GroupsTemplate = (args) => ({
@variant={{accordion.accordionVariant}}
>
<:content>
<div class="p-3 m-2" style="color: #ffffff; background-color: #424651;" >
<div class="p-3 m-2" {{style color='#ffffff' backgroundColor='#424651'}} >
<AkTypography @variant="subtitle1" @color="inherit">This is an accordion content</AkTypography>
</div>
</:content>
Expand All @@ -321,15 +324,15 @@ const MountAndUnmountContentTemplate = (args) => ({
<AkAccordion
@id="accordion1"
@isExpanded={{this.accordion1}}
@onChange={{action this.handleChange}}
@onChange={{this.handleChange}}
@summaryText="Mounts content on expand"
@summaryIconName={{this.summaryIconName}}
@mountContentOnExpand={{this.mountContentOnExpand}}
@disabled={{this.disabled}}
@variant={{this.accordionVariant}}
>
<:content>
<div class="p-3 m-2" style="color: #ffffff; background-color: #424651;" >
<div class="p-3 m-2" {{style color='#ffffff' backgroundColor='#424651'}} >
<AkTypography @variant="subtitle1" @color="inherit">This is an accordion content that mounts only after first expansion</AkTypography>
</div>
</:content>
Expand All @@ -342,15 +345,15 @@ const MountAndUnmountContentTemplate = (args) => ({
<AkAccordion
@id="accordion2"
@isExpanded={{this.accordion2}}
@onChange={{action this.handleChange}}
@onChange={{this.handleChange}}
@summaryText="Unmounts content on collapse"
@summaryIconName={{this.summaryIconName}}
@unmountContentOnCollapse={{this.unmountContentOnCollapse}}
@disabled={{this.disabled}}
@variant="primary"
>
<:content>
<div class="p-3 m-2" style="color: #ffffff; background-color: #424651;" >
<div class="p-3 m-2" {{style color='#ffffff' backgroundColor='#424651'}} >
<AkTypography @variant="subtitle1" @color="inherit">This is an accordion content that unmounts on collapse.</AkTypography>
</div>
</:content>
Expand All @@ -367,9 +370,7 @@ const MountAndUnmountContentTemplate = (args) => ({
unmountContentOnCollapse: true,
accordion1: false,
accordion2: false,
handleChange(id) {
this.set(id, !this[id]);
},
handleChange: action(handleChangeId),
},
});

Expand Down
4 changes: 2 additions & 2 deletions app/components/ak-autocomplete/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@
{{/if}}

{{else}}
{{#each this.filteredOptions as |option|}}
{{#each this.filteredOptions as |option idx|}}
<AkList::Item
data-test-ak-autocomplete-item
@button={{true}}
@divider={{not-eq this.filteredOptions.lastObject option}}
@divider={{not-eq this.filteredOptionsLastIndex idx}}
{{on 'click' (fn this.onOptionClick option)}}
>
{{yield option}}
Expand Down
15 changes: 7 additions & 8 deletions app/components/ak-autocomplete/index.stories.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { action } from '@ember/object';
import { hbs } from 'ember-cli-htmlbars';

export default {
Expand All @@ -24,19 +25,17 @@ const objectOptions = [
{ label: 'username2' },
];

const AutocompleteTemplate = (args) => {
const actions = {
onChange(searchValue) {
this.set('searchQuery', searchValue);
},
};
function onChange(searchValue) {
this.set('searchQuery', searchValue);
}

const AutocompleteTemplate = (args) => {
return {
template: hbs`
<AkAutocomplete
@options={{this.options}}
@searchQuery={{this.searchQuery}}
@onChange={{action this.onChange}}
@onChange={{this.handleChange}}
@loading={{this.loadingOptions}}
@filterFn={{this.filterFn}}
@filterKey={{this.filterKey}}
Expand All @@ -52,7 +51,7 @@ const AutocompleteTemplate = (args) => {
`,
context: {
...args,
...actions,
handleChange: action(onChange),
options: args.objectOptions ? objectOptions : stringOptions,
},
};
Expand Down
4 changes: 4 additions & 0 deletions app/components/ak-autocomplete/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ export default class AkAutocompleteComponent<T> extends Component<
return this.args.options;
}

get filteredOptionsLastIndex() {
return this.filteredOptions.length - 1;
}

get filteredOptions() {
const query = this.searchQuery.toLowerCase();

Expand Down
26 changes: 15 additions & 11 deletions app/components/ak-checkbox-tree/index.stories.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { action } from '@ember/object';
import { hbs } from 'ember-cli-htmlbars';

export default {
Expand Down Expand Up @@ -93,14 +94,13 @@ const TREE_DATA = [
},
];

const actions = {
onExpand(expandedItems) {
this.set('expanded', expandedItems);
},
onCheck(checkedItems) {
this.set('checked', checkedItems);
},
};
function onExpand(expandedItems) {
this.set('expanded', expandedItems);
}

function onCheck(checkedItems) {
this.set('checked', checkedItems);
}

const Template = (args) => ({
template: hbs`
Expand All @@ -109,11 +109,15 @@ const Template = (args) => ({
@expanded={{this.expanded}}
@cascade={{this.cascade}}
@checked={{this.checked}}
@onCheck={{action this.onCheck}}
@onExpand={{action this.onExpand}}
@onCheck={{this.onCheck}}
@onExpand={{this.onExpand}}
/>
`,
context: { ...args, ...actions },
context: {
...args,
onCheck: action(onCheck),
onExpand: action(onExpand),
},
});

export const Basic = Template.bind({});
Expand Down
Loading

0 comments on commit fb6c306

Please sign in to comment.