Skip to content

Commit

Permalink
Cs 7919 hide crm deal embedded format icon (#2093)
Browse files Browse the repository at this point in the history
* hide card view icon on CRM Deal

* fix glint
  • Loading branch information
lucaslyl authored Jan 28, 2025
1 parent 316d35f commit 959fdd8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export default class ViewSelector extends Component<Signature> {
{ id: 'strip', icon: StripIcon },
{ id: 'grid', icon: GridIcon },
];
viewOptions = this.args.items ?? this.standardViewOptions;

get viewOptions() {
return this.args.items ?? this.standardViewOptions;
}

get selectedId() {
return this.args.selectedId ?? (this.viewOptions[0] as ViewItem).id;
Expand Down
40 changes: 40 additions & 0 deletions packages/experiments-realm/crm-app.gts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,22 @@ import type { Deal } from './crm/deal';
import DealSummary from './crm/deal-summary';
import { CRMTaskPlanner } from './crm/task-planner';

import type { TemplateOnlyComponent } from '@ember/component/template-only';
import {
Card as CardIcon,
Grid3x3 as GridIcon,
Rows4 as StripIcon,
} from '@cardstack/boxel-ui/icons';

type ViewOption = 'card' | 'strip' | 'grid';

interface ViewItem {
icon: TemplateOnlyComponent<{
Element: SVGElement;
}>;
id: ViewOption;
}

const CONTACT_FILTERS: LayoutFilter[] = [
{
displayName: 'All Contacts',
Expand Down Expand Up @@ -132,6 +146,29 @@ class CrmAppTemplate extends Component<typeof AppCard> {
@tracked activeTabId: string | undefined = this.args.model.tabs?.[0]?.tabId;
@tracked tabs = this.args.model.tabs;
@tracked private selectedView: ViewOption = 'card';

// Only show strip and grid views for Deal tab for now
get dealView(): ViewItem[] {
return [
{ id: 'strip', icon: StripIcon },
{ id: 'grid', icon: GridIcon },
];
}

get commonViews(): ViewItem[] {
return [
{ id: 'card', icon: CardIcon },
{ id: 'strip', icon: StripIcon },
{ id: 'grid', icon: GridIcon },
];
}

get tabViews(): ViewItem[] {
const views =
this.activeTabId === 'Deal' ? this.dealView : this.commonViews;
return views;
}

@tracked private searchKey = '';
@tracked private deals: Deal[] = [];

Expand Down Expand Up @@ -203,11 +240,13 @@ class CrmAppTemplate extends Component<typeof AppCard> {

//Tabs
@action setActiveTab(id: string) {
this.selectedView = id === 'Deal' ? 'strip' : 'card';
this.activeTabId = id;
this.searchKey = '';
this.setActiveFilter();
this.loadDealCards.perform();
}

get headerColor() {
return (
Object.getPrototypeOf(this.args.model).constructor.headerColor ??
Expand Down Expand Up @@ -425,6 +464,7 @@ class CrmAppTemplate extends Component<typeof AppCard> {
class='view-menu content-header-row-2'
@selectedId={{this.selectedView}}
@onChange={{this.onChangeView}}
@items={{this.tabViews}}
/>
{{/if}}
{{#if this.activeFilter.sortOptions.length}}
Expand Down

0 comments on commit 959fdd8

Please sign in to comment.