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

feat(): date option #1392

Merged
merged 8 commits into from
Jan 29, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const MetricSchema: IConfigurationSchema = {
valueType: {
type: "string",
default: "string",
enum: ["string", "number"],
enum: ["string", "number", "date"],
},
dynamicMetric: {
type: "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,24 @@ export const buildUiSchema = (
],
},
},
// {
// labelKey: `${i18nScope}.fields.metrics.value.label`,
// scope: "/properties/_metric/properties/value",
// type: "Control",
// rule: SHOW_FOR_STATIC_AND_DATE_RULE_ENTITY,
// options: {
// control: "hub-field-input-date",
// messages: [
// {
// type: "ERROR",
// keyword: "required",
// labelKey: `${i18nScope}.fields.metrics.value.message.required`,
// icon: true,
// },
// ],
// },
// },
{
labelKey: `${i18nScope}.fields.metrics.value.label`,
scope: "/properties/_metric/properties/value",
type: "Control",
rule: SHOW_FOR_STATIC_AND_DATE_RULE_ENTITY,
options: {
control: "hub-field-input-date",
clearOnHidden: true,
messages: [
{
type: "ERROR",
keyword: "required",
labelKey: `${i18nScope}.fields.metrics.value.message.required`,
icon: true,
},
],
},
},
{
scope: "/properties/_metric/properties/dynamicMetric",
type: "Control",
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/metrics/resolveMetric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function resolveStaticValueMetric(
name: metric.entityInfo.name,
type: metric.entityInfo.type,
[fieldName]: source.value,
valueType: source.valueType,
},
};
return Promise.resolve({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,37 +134,38 @@ describe("buildUiSchema: metric", () => {
],
},
},
// {
// labelKey: `some.scope.fields.metrics.value.label`,
// scope: "/properties/_metric/properties/value",
// type: "Control",
// rule: {
// condition: {
// schema: {
// properties: {
// _metric: {
// properties: {
// type: { const: "static" },
// valueType: { const: "date" },
// },
// },
// },
// },
// },
// effect: UiSchemaRuleEffects.SHOW,
// },
// options: {
// control: "hub-field-input-date",
// messages: [
// {
// type: "ERROR",
// keyword: "required",
// labelKey: `some.scope.fields.metrics.value.message.required`,
// icon: true,
// },
// ],
// },
// },
{
labelKey: `some.scope.fields.metrics.value.label`,
scope: "/properties/_metric/properties/value",
type: "Control",
rule: {
condition: {
schema: {
properties: {
_metric: {
properties: {
type: { const: "static" },
valueType: { const: "date" },
},
},
},
},
},
effect: UiSchemaRuleEffects.SHOW,
},
options: {
control: "hub-field-input-date",
clearOnHidden: true,
messages: [
{
type: "ERROR",
keyword: "required",
labelKey: `some.scope.fields.metrics.value.message.required`,
icon: true,
},
],
},
},
{
scope: "/properties/_metric/properties/dynamicMetric",
type: "Control",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/test/metrics/resolveMetric.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe("resolveMetric:", () => {
source: {
type: "static-value",
value: 100000,
valueType: "number",
},
entityInfo: {
id: "00c",
Expand All @@ -76,6 +77,7 @@ describe("resolveMetric:", () => {
name: "Some Project Name",
type: "Hub Project",
initiativeBudget: 100000,
valueType: "number",
},
},
]);
Expand Down
Loading