Skip to content

Commit

Permalink
implemented working tooltip/help message and better styling
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewPhilbin committed Aug 22, 2023
1 parent 84364e5 commit 1f538a9
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export const CustomArrayFieldTemplate = props => {
const addLabel = props.uiSchema["ui:addLabel"] ||
<FormattedMessage {...messages.addPriorityRuleLabel} />
const deleteLabel = props.uiSchema["ui:deleteLabel"]

const itemFields = _map(props.items, element =>
<div
key={element.index}
Expand Down Expand Up @@ -96,7 +95,7 @@ export const CustomArrayFieldTemplate = props => {
{props.canAdd &&
<div className="array-field__block-controls">
<button
className="mr-button mr-button mr-button--small"
className="mr-button mr-button--small"
onClick={props.onAddClick}
>
{addLabel}
Expand Down
1 change: 1 addition & 0 deletions src/lang/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,7 @@
"Profile.form.notificationSubscriptions.label": "Notification Subscriptions",
"Profile.form.seeTagFixSuggestions.description": "User will see tag fix suggestions if they are provided.",
"Profile.form.seeTagFixSuggestions.label": "See Tag Fix Suggestions",
"Profile.form.systemNotifications.description": "This is a test system notifications help label",
"Profile.form.uniqueCustomBasemap.error": "Custom Basemap names must be unique",
"Profile.form.yes.label": "Yes",
"Profile.noUser": "User not found or you are unauthorized to view this user.",
Expand Down
5 changes: 5 additions & 0 deletions src/pages/Profile/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ export default defineMessages({
"or as a daily digest)"
},

systemNotificationsDescription: {
id: "Profile.form.systemNotifications.description",
defaultMessage: "This is a test system notifications help label",
},

yesLabel: {
id: "Profile.form.yes.label",
defaultMessage: "Yes",
Expand Down
23 changes: 20 additions & 3 deletions src/pages/Profile/UserSettings/NotificationSettingsSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from "../../../services/Notification/NotificationSubscription/NotificationSubscription";
import MarkdownContent from "../../../components/MarkdownContent/MarkdownContent";
import messages from "../Messages";
import { CustomFieldTemplate } from '../../../components/Custom/RJSFFormFieldAdapter/RJSFFormFieldAdapter';

const createSubscriptionInput = (
name,
Expand All @@ -26,6 +27,7 @@ const createSubscriptionInput = (
defaultSelection,
) => {
return {
name: name,
title: `${
notificationLabels[`${name}Long`] || notificationLabels[name]
} ${intl.formatMessage(messages.notificationLabel)}`,
Expand All @@ -37,6 +39,7 @@ const createSubscriptionInput = (
};

export const transformErrors = (intl) => (errors) => {
console.log('errors', errors)
return errors.map(error => {
if (error.name === "format") {
const formatMessage = intl.formatMessage(messages.errorFormatMessage)
Expand Down Expand Up @@ -92,14 +95,24 @@ export const jsSchema = (intl) => {
);
});


const notificationObject = {}
items.forEach((item, i) => {
notificationObject[i] = item
})

return {
$schema: "http://json-schema.org/draft-07/schema#",
type: "object",
properties: {
// notificationSubscriptions: {
// title: intl.formatMessage(messages.notificationSubscriptionsLabel),
// type: "array",
// items: items,
// },
notificationSubscriptions: {
title: intl.formatMessage(messages.notificationSubscriptionsLabel),
type: "array",
items: items,
properties: notificationObject,
},
email: {
title: intl.formatMessage(messages.emailLabel),
Expand Down Expand Up @@ -134,11 +147,15 @@ export const uiSchema = (intl) => {

notificationSubscriptions: {
classNames: "no-legend notification-subscriptions",
0: {
"ui:help": intl.formatMessage(messages.systemNotificationsDescription),
"ui:FieldTemplate": CustomFieldTemplate,
},
},
"ui:options": {
orderable: false,
removable: false,
},
},
"ui:order": ["email", "notificationSubscriptions"],
"ui:showTitle": false,

Expand Down
12 changes: 8 additions & 4 deletions src/pages/Profile/UserSettings/UserSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
CustomSelectWidget,
NoFieldsetObjectFieldTemplate,
CustomArrayFieldTemplate,
CustomNotificationSettingsArrayFieldTemplate,
CustomFieldTemplate
} from "../../../components/Custom/RJSFFormFieldAdapter/RJSFFormFieldAdapter";
import {
jsSchema as settingsJsSchema,
Expand Down Expand Up @@ -63,7 +63,7 @@ class UserSettings extends Component {
if (!this.areBasemapNamesUnique(settings.customBasemaps)) {
return;
}

console.log('settings in save settings', settings)
this.setState({ isSaving: true, saveComplete: false });

const editableUser = AsEditableUser(_cloneDeep(settings));
Expand Down Expand Up @@ -138,7 +138,6 @@ class UserSettings extends Component {
if (_isEmpty(settings)) {
return;
}

this.setState({ isSaving: true, saveComplete: false });
this.props
.updateNotificationSubscriptions(this.props.user.id, settings)
Expand Down Expand Up @@ -192,6 +191,8 @@ class UserSettings extends Component {
saveComplete: false,
});

console.log(formData)

const subscriptionsObject = _fromPairs(
_map(formData.notificationSubscriptions, (setting, index) => [
keysWithCountTypes[index],
Expand Down Expand Up @@ -240,7 +241,7 @@ class UserSettings extends Component {
this.props.loadCompleteUser(this.props.user.id);
}
}
console.log(this.state)
// console.log(this.state)
}

render() {
Expand Down Expand Up @@ -364,6 +365,9 @@ class UserSettings extends Component {
this.notificationsChangeHandler(userSettings, params)
}
ObjectFieldTemplate={NoFieldsetObjectFieldTemplate}
// ArrayFieldTemplate={testCustomArrayFieldTemplate}
// FieldTemplate={CustomFieldTemplate}
// CustomFields={customFields}
>
<div className="form-controls" />
</Form>
Expand Down
4 changes: 4 additions & 0 deletions src/styles/components/forms.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
@apply mr-mb-0;
}
}

.control-label {
@apply mr-cursor-default
}
}

}
Expand Down

0 comments on commit 1f538a9

Please sign in to comment.