Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cs 7919 hide crm deal embedded format icon #2093

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for here,I changing this to a getter makes viewOptions reactive


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

import type { ComponentLike } from '@glint/template';
import {
Card as CardIcon,
Grid3x3 as GridIcon,
Rows4 as StripIcon,
} from '@cardstack/boxel-ui/icons';

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

interface ViewItem {
icon: ComponentLike;
id: string;
}

const CONTACT_FILTERS: LayoutFilter[] = [
{
displayName: 'All Contacts',
Expand Down Expand Up @@ -132,6 +144,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 +238,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 +462,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
Loading