feat: weights per attribute UI (#18109)
* wip attribut weights * edit sheet and display in table * add shrink so badges dont split * push changes to support weights on csv export * fix typing issue * type error * fall back to 100 weight --------- Co-authored-by: Udit Takkar <[email protected]>
This commit is contained in:
1 parent
b6d6b7cdb4
commit
ee3c08918a
18 files changed
+190
-67
No files matched your search
@@ -21,6 +21,7 @@ import {
|
||||
const AttributeFormSchema = z.object({
|
||||
attrName: z.string().min(1),
|
||||
isLocked: z.boolean().optional(),
|
||||
isWeightsEnabled: z.boolean().optional(),
|
||||
type: z.enum(["TEXT", "NUMBER", "SINGLE_SELECT", "MULTI_SELECT"]),
|
||||
options: z.array(
|
||||
z.object({
|
||||
@@ -193,6 +194,23 @@ export function AttributeForm({ initialValues, onSubmit, header }: AttributeForm
|
||||
);
|
||||
}}
|
||||
/>
|
||||
{["SINGLE_SELECT", "MULTI_SELECT"].includes(watchedType) && (
|
||||
<Controller
|
||||
name="isWeightsEnabled"
|
||||
render={({ field: { value, onChange } }) => {
|
||||
return (
|
||||
<SettingsToggle
|
||||
title={t("attribute_weight_enabled")}
|
||||
description={t("attribute_weight_enabled_description")}
|
||||
checked={value}
|
||||
onCheckedChange={(checked) => {
|
||||
onChange(checked);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<InputField label={t("name")} required {...form.register("attrName")} />
|
||||
<Controller
|
||||
name="type"
|
||||
|
||||
+1
-1
@@ -1,7 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useParams } from "next/navigation";
|
||||
import React from "react";
|
||||
import { useFormContext } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
|
||||
@@ -53,6 +52,7 @@ function CreateAttributesPage() {
|
||||
type: attribute.data.type,
|
||||
options: attribute.data.options,
|
||||
isLocked: attribute.data.isLocked,
|
||||
isWeightsEnabled: attribute.data.isWeightsEnabled,
|
||||
}}
|
||||
header={<EditAttributeHeader isPending={mutation.isPending} />}
|
||||
onSubmit={(values) => {
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
DropdownMenuItem,
|
||||
Icon,
|
||||
showToast,
|
||||
Badge,
|
||||
} from "@calcom/ui";
|
||||
|
||||
import { DeleteAttributeModal } from "./DeleteAttributeModal";
|
||||
@@ -75,6 +76,12 @@ function AttributeItem({
|
||||
<span>{t("number_of_options", { count: attribute.options.length })}</span>
|
||||
</>
|
||||
)}
|
||||
{attribute.isWeightsEnabled && (
|
||||
<>
|
||||
<span className="text-muted">•</span>
|
||||
<Badge>{t("attribute_weight_enabled")}</Badge>
|
||||
</>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex gap-4">
|
||||
|
||||
Reference in new issue
Block a user