Skip to content
This repository has been archived by the owner on Feb 9, 2022. It is now read-only.

Commit

Permalink
Feature/track text color (#245)
Browse files Browse the repository at this point in the history
* add text_color to form

* fix normaliation
  • Loading branch information
santipalenque authored Jul 10, 2023
1 parent a5da104 commit 47d7866
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/actions/event-category-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ const normalizeEntity = (entity) => {
//remove # from color hexa
if (normalizedEntity.color)
normalizedEntity.color = normalizedEntity.color.substr(1);

//remove # from text color hexa
if (normalizedEntity.text_color)
normalizedEntity.text_color = normalizedEntity.text_color.substr(1);

normalizedEntity.session_count = parseInt(entity.session_count);
normalizedEntity.alternate_count = parseInt(entity.alternate_count);
Expand Down
12 changes: 11 additions & 1 deletion src/components/forms/event-category-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class EventCategoryForm extends React.Component {
error={hasErrors('code', errors)}
/>
</div>
<div className="col-md-4">
<div className="col-md-2">
<label> {T.translate("edit_event_category.color")} *</label>
<Input
id="color"
Expand All @@ -150,6 +150,16 @@ class EventCategoryForm extends React.Component {
className="form-control"
/>
</div>
<div className="col-md-2">
<label> {T.translate("edit_event_category.text_color")} *</label>
<Input
id="text_color"
type="color"
value={entity.text_color}
onChange={this.handleChange}
className="form-control"
/>
</div>
</div>
<div className="row form-group">
<div className="col-md-12">
Expand Down
1 change: 1 addition & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,7 @@
"name": "Name",
"code": "Code",
"color": "Color",
"text_color": "Text Color",
"description": "Description",
"pic": "Image",
"number_sessions": "# of Sessions",
Expand Down
8 changes: 1 addition & 7 deletions src/reducers/events/event-category-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const DEFAULT_ENTITY = {
name : '',
code : '',
color : '#DADADA',
text_color : '#000000',
description : '',
session_count : 0,
alternate_count : 0,
Expand Down Expand Up @@ -62,16 +63,13 @@ const eventCategoryReducer = (state = DEFAULT_STATE, action) => {
return {...state, entity: {...DEFAULT_ENTITY}, errors: {} };
}
}
break;
case SET_CURRENT_SUMMIT:
case RESET_EVENT_CATEGORY_FORM: {
return {...state, entity: {...DEFAULT_ENTITY}, errors: {} };
}
break;
case UPDATE_EVENT_CATEGORY: {
return {...state, entity: {...payload}, errors: {} };
}
break;
case EVENT_CATEGORY_ADDED:
case RECEIVE_EVENT_CATEGORY: {
let entity = {...payload.response};
Expand All @@ -84,20 +82,16 @@ const eventCategoryReducer = (state = DEFAULT_STATE, action) => {

return {...state, errors: {}, entity: {...DEFAULT_ENTITY, ...entity} };
}
break;
case EVENT_CATEGORY_IMAGE_ATTACHED: {
let image = {...payload.response};
return {...state, entity: {...state.entity, icon_url: image.url} };
}
break;
case EVENT_CATEGORY_IMAGE_DELETED: {
return {...state, entity: {...state.entity, icon_url: null} };
}
break;
case VALIDATE: {
return {...state, errors: payload.errors };
}
break;
default:
return state;
}
Expand Down

0 comments on commit 47d7866

Please sign in to comment.