Skip to content

Commit

Permalink
Adjustments to PropertyFieldColorConfiguration #433
Browse files Browse the repository at this point in the history
  • Loading branch information
olemp committed Nov 3, 2022
1 parent eaa2721 commit d71d703
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
1 change: 1 addition & 0 deletions SharePointFramework/ProjectWebParts/src/loc/mystrings.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare interface IProjectWebPartsStrings {
RevertDefaultColorConfigurationText: string
RiskMatrix_Header_ExtremelyLow: string
RiskMatrix_Header_VeryCritical: string
RiskMatrixColorScaleConfigLabel: string
Expand Down
5 changes: 3 additions & 2 deletions SharePointFramework/ProjectWebParts/src/loc/nb-no.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
define([], function () {
return {
RiskMatrixColorScaleConfigLabel:'Fargekonfigurasjon',
RevertDefaultColorConfigurationText: 'Bruk standard',
RiskMatrixColorScaleConfigLabel: 'Fargekonfigurasjon',
RiskMatrixSizeLabel: 'Størrelse',
RiskMatrixFullWidthLabel: 'Bruk full bredde',
ParentProjectsGroupName: 'Overordnede prosjekter',
Expand Down Expand Up @@ -62,7 +63,7 @@ define([], function () {
PhaseChecklistViewUrl: 'Lists/Fasesjekkliste/AllItems.aspx',
PickReportText: 'Velg rapport',
SaveText: 'Lagre',
SaveColorConfigurationText:'Lagre fargekonfigurasjon',
SaveColorConfigurationText: 'Lagre',
RiskMatrixGroupName: 'Risikomatrise',
ProjectStatusProjectPropertiesGroupName: 'Prosjektegenskaper (Statusseksjoner)',
SettingsGroupName: 'Innstillinger',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
.root {
.container {
display: flex;
flex-direction: rowx;
flex-direction: row;
justify-content: space-between;
flex-wrap: wrap;
margin: 20px 0 0 0;
}
.saveBtn {
.actions {
display: flex;
flex-direction: row;
justify-content: flex-start;
flex-wrap: nowrap;
margin: 15px 0 0 0;

> div, > button {
flex: 1;
margin: 0 8px 0 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DefaultButton, Label, Slider } from '@fluentui/react'
import { DefaultButton, Label, PrimaryButton, Slider } from '@fluentui/react'
import { MATRIX_DEFAULT_COLOR_SCALE_CONFIG } from 'components/RiskMatrix/types'
import strings from 'ProjectWebPartsStrings'
import React, { FC } from 'react'
Expand All @@ -10,9 +10,14 @@ import { usePropertyFieldColorConfiguration } from './usePropertyFieldColorConfi
export const PropertyFieldColorConfiguration: FC<IPropertyFieldColorConfigurationProps> = (
props
) => {
const { count, setCount, config, onColorChange, onSave } = usePropertyFieldColorConfiguration(
props
)
const {
count,
setCount,
config,
onColorChange,
onSave,
onRevertDefault
} = usePropertyFieldColorConfiguration(props)
return (
<div className={styles.root}>
<Label>{props.label}</Label>
Expand All @@ -27,12 +32,17 @@ export const PropertyFieldColorConfiguration: FC<IPropertyFieldColorConfiguratio
/>
))}
</div>
<div className={styles.saveBtn}>
<DefaultButton
<div className={styles.actions}>
<PrimaryButton
text={strings.SaveColorConfigurationText}
onClick={onSave && onSave}
disabled={!onSave}
/>
<DefaultButton
text={strings.RevertDefaultColorConfigurationText}
onClick={onRevertDefault && onRevertDefault}
disabled={!onRevertDefault}
/>
</div>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { MATRIX_DEFAULT_COLOR_SCALE_CONFIG } from 'components/RiskMatrix'
import { useState } from 'react'
import _, { last } from 'underscore'
import { IPropertyFieldColorConfigurationProps } from '../../types'
Expand Down Expand Up @@ -35,10 +36,14 @@ export function usePropertyFieldColorConfiguration(props: IPropertyFieldColorCon
}

let onSave: () => void = null
let onRevertDefault: () => void = null

if (!_.isEqual(props.value, config)) {
onSave = () => props.onChange(null, config)
}
if (!_.isEqual(MATRIX_DEFAULT_COLOR_SCALE_CONFIG, config)) {
onRevertDefault = () => props.onChange(null, undefined)
}

return { config, count, setCount, onColorChange, onSave } as const
return { config, count, setCount, onColorChange, onSave, onRevertDefault } as const
}

0 comments on commit d71d703

Please sign in to comment.