From 1134197eacb55207fd983f114328bf2ec3f411eb Mon Sep 17 00:00:00 2001 From: becky Date: Mon, 2 Nov 2020 13:38:42 -0800 Subject: [PATCH 1/5] Fixed Console Errors Throughout Mostly PropTypes and properties of Grid errors --- app/javascript/components/ActionItemCard/index.js | 6 +++--- .../components/ActionItemCreationPage/index.js | 4 ++-- app/javascript/components/ActionItemParticipant/index.js | 2 +- .../components/ActionItemSearchParticipants/index.js | 9 ++++----- app/javascript/components/EnhancedTable/index.js | 5 ++--- app/javascript/components/LoadModal/index.js | 2 +- app/javascript/components/Main/index.js | 2 -- app/javascript/components/ParticipantCard/styles.js | 1 - 8 files changed, 13 insertions(+), 18 deletions(-) diff --git a/app/javascript/components/ActionItemCard/index.js b/app/javascript/components/ActionItemCard/index.js index f1614e2d..6419a133 100644 --- a/app/javascript/components/ActionItemCard/index.js +++ b/app/javascript/components/ActionItemCard/index.js @@ -253,7 +253,7 @@ function ActionItemCard({ item container justify="flex-end" - style={{ 'padding-left': '16px', width: 'calc(100% - 100px)' }} + style={{ paddingLeft: '16px', width: 'calc(100% - 100px)' }} > {/* Make sure renderClose + participantShowPage are not both true, or else you get two edit buttons. */} {renderCompleteButton()} @@ -280,8 +280,8 @@ ActionItemCard.propTypes = { removeActionItem: PropTypes.func, addBorderBottom: PropTypes.bool, participantShowPage: PropTypes.bool, - initialCompletedStaff: PropTypes.bool.isRequired, - initialCompletedParticipant: PropTypes.bool.isRequired, + initialCompletedStaff: PropTypes.bool, + initialCompletedParticipant: PropTypes.bool, assignmentId: PropTypes.number, }; diff --git a/app/javascript/components/ActionItemCreationPage/index.js b/app/javascript/components/ActionItemCreationPage/index.js index d8f01a29..426bf01d 100644 --- a/app/javascript/components/ActionItemCreationPage/index.js +++ b/app/javascript/components/ActionItemCreationPage/index.js @@ -512,7 +512,7 @@ class ActionItemCreationPage extends React.Component { ); const forwardButton = ( - + diff --git a/app/javascript/components/ActionItemParticipant/index.js b/app/javascript/components/ActionItemParticipant/index.js index d8bd4aee..c688c598 100644 --- a/app/javascript/components/ActionItemParticipant/index.js +++ b/app/javascript/components/ActionItemParticipant/index.js @@ -44,7 +44,7 @@ function ActionItemParticipant({ container direction="row" alignItems="center" - justifyContent="flex-start" + justifycontent="flex-start" zeroMinWidth style={{ width: '80%' }} > diff --git a/app/javascript/components/ActionItemSearchParticipants/index.js b/app/javascript/components/ActionItemSearchParticipants/index.js index 438b5d7a..dc11432a 100644 --- a/app/javascript/components/ActionItemSearchParticipants/index.js +++ b/app/javascript/components/ActionItemSearchParticipants/index.js @@ -177,14 +177,13 @@ class ActionItemSearchParticipants extends React.Component { className={classes.boundaryBox} direction="column" alignItems="center" - justifyContent="space-evenly" + justifycontent="space-evenly" + justify="center" > {/* Filter By Category */} FILTER BY CATEGORY - - {this.statusButtons()} - + {this.statusButtons()} {/* Search for an individual */} @@ -205,7 +204,7 @@ class ActionItemSearchParticipants extends React.Component { {/* Select All Button */} - + {headCell.sortable ? ( @@ -124,7 +123,7 @@ function EnhancedTable(props) { - {titleText} + {titleText} diff --git a/app/javascript/components/Main/index.js b/app/javascript/components/Main/index.js index c8204778..58c85bb5 100644 --- a/app/javascript/components/Main/index.js +++ b/app/javascript/components/Main/index.js @@ -61,7 +61,6 @@ function Main(props) { { @@ -155,7 +154,6 @@ function Main(props) { ({ case 'Studio': return theme.palette.common.studio; default: - console.error('Participant has no status'); return theme.palette.common.darkestBlue; } }, From 00f62a26ea1ed4c28a02fbd052086546f1fa7fe6 Mon Sep 17 00:00:00 2001 From: Jessi Shank Date: Thu, 5 Nov 2020 11:32:31 -0800 Subject: [PATCH 2/5] using original encrypted credentials file since i found the master key --- config/credentials.yml.enc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc index 6329142b..f1b9ccaa 100644 --- a/config/credentials.yml.enc +++ b/config/credentials.yml.enc @@ -1 +1 @@ -wAPvYLoQ4I0Stta+1ndMCaixAECubpqZCpWXcf62evlD9hnSM9H2f6Yfc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AgaSsK0nfnoWVwtLvagwiaA6hKTeFHQFj0uESd50Qt19P09WnN0daLUsA==--kXdPerAvKX9BNqcO--oBpfONbfQTSKGMIe526QIw== \ No newline at end of file From f7111ab980034a3448b0c598b90ae22c6fbdb296 Mon Sep 17 00:00:00 2001 From: becky Date: Thu, 12 Nov 2020 11:59:09 -0800 Subject: [PATCH 3/5] Added Rich Text for Assignment Descriptions Added MUI Rich Text editor to ActionItemForm and ActionItemModal for assignment descriptions and created defaultTheme for MUI theme in the style pages. Added Rich Text rendering to ViewMoreModal and ActionItemCard making backward compatible and adjusting the styles for AssignmentList to accomodate changes. --- .../components/ActionItemCard/index.js | 9 ++-- .../components/ActionItemCard/styles.js | 4 +- .../components/ActionItemForm/index.js | 35 ++++++++++++-- .../components/ActionItemForm/styles.js | 32 ++++++++++++- .../components/ActionItemModal/index.js | 47 ++++++++++++------- .../components/ActionItemModal/styles.js | 32 ++++++++++++- .../components/ViewMoreModal/index.js | 7 +-- 7 files changed, 129 insertions(+), 37 deletions(-) diff --git a/app/javascript/components/ActionItemCard/index.js b/app/javascript/components/ActionItemCard/index.js index 6419a133..b4103234 100644 --- a/app/javascript/components/ActionItemCard/index.js +++ b/app/javascript/components/ActionItemCard/index.js @@ -18,6 +18,7 @@ import { apiPatch } from 'utils/axios'; import * as Sentry from '@sentry/browser'; import formatDate from 'utils/utils'; import styles from './styles'; +import MUIRichTextEditor from 'mui-rte'; function ActionItemCard({ classes, userType, @@ -43,7 +44,9 @@ function ActionItemCard({ initialCompletedParticipant, ); const [completedStaff, setCompletedStaff] = useState(initialCompletedStaff); - + const renderRichText = desc => ( + + ); const renderSelectIcon = () => ( {selected ? : } @@ -219,7 +222,7 @@ function ActionItemCard({ > - {description} + {description[0] === '{' ? renderRichText(description) : description} @@ -244,7 +247,7 @@ function ActionItemCard({ > {dueDate ? ( - + Due: {formatDate(dueDate)} ) : null} diff --git a/app/javascript/components/ActionItemCard/styles.js b/app/javascript/components/ActionItemCard/styles.js index 25ecfbcf..08eb2f36 100644 --- a/app/javascript/components/ActionItemCard/styles.js +++ b/app/javascript/components/ActionItemCard/styles.js @@ -35,9 +35,9 @@ const styles = theme => ({ descriptionStyle: { textOverflow: 'ellipsis', fontSize: '14px', - overflow: 'hidden', + overflow: 'auto', lineHeight: '1.5em', - height: '1.5em', + maxHeight: '4em', maxWidth: 'calc(100% - 64px)', }, buttonStyle: { diff --git a/app/javascript/components/ActionItemForm/index.js b/app/javascript/components/ActionItemForm/index.js index 51d36c64..e788b3f1 100644 --- a/app/javascript/components/ActionItemForm/index.js +++ b/app/javascript/components/ActionItemForm/index.js @@ -1,5 +1,5 @@ import React, { useState, useRef } from 'react'; -import { withStyles, ThemeProvider } from '@material-ui/core/styles'; +import { withStyles, ThemeProvider, MuiThemeProvider } from '@material-ui/core/styles'; import Grid from '@material-ui/core/Grid'; import TextField from '@material-ui/core/TextField'; import Typography from '@material-ui/core/Typography'; @@ -9,7 +9,9 @@ import Button from '@material-ui/core/Button'; import Paper from '@material-ui/core/Paper'; import ActionItemCategoryTag from 'components/ActionItemCategoryTag'; import theme from 'utils/theme'; -import styles from './styles'; +import { styles, defaultTheme } from './styles'; +import MUIRichTextEditor from 'mui-rte'; +import { convertToRaw } from 'draft-js'; function ActionItemForm({ classes, @@ -36,6 +38,11 @@ function ActionItemForm({ setCategory({ target: { value: newCategory } }); }; + const handleDescriptionChange = state => { + const value = JSON.stringify(convertToRaw(state.getCurrentContent())); + setDescription({ target: {value} }) + }; + const categoryList = categories.map(category => { const isSelectedCategory = categorySelected && categorySelected === category; @@ -51,7 +58,6 @@ function ActionItemForm({ }); const allFieldsFilled = title && description && categorySelected; - return ( @@ -102,7 +108,26 @@ function ActionItemForm({ > Assignment Description - + + + {/* setDescription(e)} @@ -113,7 +138,7 @@ function ActionItemForm({ required error={failedSubmit && !description} rows={2} - /> + /> */} Due Date (Optional) diff --git a/app/javascript/components/ActionItemForm/styles.js b/app/javascript/components/ActionItemForm/styles.js index 1f2bf25d..1cce9364 100644 --- a/app/javascript/components/ActionItemForm/styles.js +++ b/app/javascript/components/ActionItemForm/styles.js @@ -1,4 +1,7 @@ -const styles = theme => ({ +import { createMuiTheme } from '@material-ui/core/styles'; +import theme from 'utils/theme'; + +const styles = () => ({ categoryButtonStyle: { fontSize: '10px', textAlign: 'center', @@ -43,4 +46,29 @@ const styles = theme => ({ }, }); -export default styles; +const defaultTheme = createMuiTheme(); +Object.assign(defaultTheme, { + overrides: { + MUIRichTextEditor: { + root: { + borderLeft: `solid 1px ${theme.palette.common.lightGrey}`, + borderRight: `solid 1px ${theme.palette.common.lightGrey}`, + borderBottom: `solid 1px ${theme.palette.common.lightGrey}`, + borderRadius: '4px', + }, + hidePlaceholder: { + display: 'block', + }, + editorContainer: { + padding: '20px', + overflow: 'auto', + height: '130px', + }, + toolbar: { + backgroundColor: theme.palette.common.lightestGrey, + }, + }, + }, +}); + +export { styles, defaultTheme }; diff --git a/app/javascript/components/ActionItemModal/index.js b/app/javascript/components/ActionItemModal/index.js index 1ad723af..911204c1 100644 --- a/app/javascript/components/ActionItemModal/index.js +++ b/app/javascript/components/ActionItemModal/index.js @@ -11,9 +11,12 @@ import { DialogContentText, Grid, } from '@material-ui/core'; -import { withStyles, ThemeProvider } from '@material-ui/core/styles'; +import { withStyles, ThemeProvider, MuiThemeProvider } from '@material-ui/core/styles'; import ActionItemCategoryTag from 'components/ActionItemCategoryTag'; -import styles from './styles'; +import { styles, defaultTheme } from './styles'; +import MUIRichTextEditor from 'mui-rte'; +import { convertToRaw } from 'draft-js'; + class ActionItemModal extends React.Component { constructor(props) { super(props); @@ -34,6 +37,11 @@ class ActionItemModal extends React.Component { this.setState({ [name]: value }); }; + handleDescriptionChange = name => state => { + const value = JSON.stringify(convertToRaw(state.getCurrentContent())); + this.setState({ [name]: value }); + }; + handleFileChange = event => { const file = event.target.files[0] ? event.target.files[0] : null; const fileURL = file ? window.URL.createObjectURL(file) : null; @@ -101,7 +109,6 @@ class ActionItemModal extends React.Component { ); }); - return ( Description - + + + diff --git a/app/javascript/components/ActionItemModal/styles.js b/app/javascript/components/ActionItemModal/styles.js index 45ecac7e..1fd0cb03 100644 --- a/app/javascript/components/ActionItemModal/styles.js +++ b/app/javascript/components/ActionItemModal/styles.js @@ -1,4 +1,7 @@ -const styles = theme => ({ +import { createMuiTheme } from '@material-ui/core/styles'; +import theme from 'utils/theme'; + +const styles = () => ({ overrides: { MuiDialogContent: { root: { @@ -120,4 +123,29 @@ const styles = theme => ({ }, }); -export default styles; +const defaultTheme = createMuiTheme(); +Object.assign(defaultTheme, { + overrides: { + MUIRichTextEditor: { + root: { + borderLeft: `solid 1px ${theme.palette.common.lightGrey}`, + borderRight: `solid 1px ${theme.palette.common.lightGrey}`, + borderBottom: `solid 1px ${theme.palette.common.lightGrey}`, + borderRadius: '4px', + }, + hidePlaceholder: { + display: 'block', + }, + editorContainer: { + padding: '20px', + overflow: 'auto', + height: '130px', + }, + toolbar: { + backgroundColor: theme.palette.common.lightestGrey, + }, + }, + }, +}); + +export { styles, defaultTheme }; diff --git a/app/javascript/components/ViewMoreModal/index.js b/app/javascript/components/ViewMoreModal/index.js index 064e07d0..4950370c 100644 --- a/app/javascript/components/ViewMoreModal/index.js +++ b/app/javascript/components/ViewMoreModal/index.js @@ -30,9 +30,6 @@ function ViewMoreModal({ const renderRichText = desc => ( ); - const renderReadOnlyTextField = desc => ( - - ); const renderCategory = categorySelected => ( @@ -101,9 +98,7 @@ function ViewMoreModal({
- {isCaseNote - ? renderRichText(description) - : renderReadOnlyTextField(description)} + {renderRichText(description)}
From 298d5fa67cb7fbcd7997e65107670afb5df3f68c Mon Sep 17 00:00:00 2001 From: Jessi Shank Date: Fri, 13 Nov 2020 10:07:39 -0800 Subject: [PATCH 4/5] starting on bulk modify flow --- app/controllers/assignments_controller.rb | 9 +++++++++ app/policies/action_item_policy.rb | 8 ++++++++ app/policies/assignment_policy.rb | 4 ++++ app/views/assignments/bulk_modify_create.html.erb | 10 ++++++++++ app/views/assignments/bulk_modify_select.html.erb | 10 ++++++++++ config/routes.rb | 13 ++++++++++++- 6 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 app/views/assignments/bulk_modify_create.html.erb create mode 100644 app/views/assignments/bulk_modify_select.html.erb diff --git a/app/controllers/assignments_controller.rb b/app/controllers/assignments_controller.rb index 216a7d96..933358e7 100644 --- a/app/controllers/assignments_controller.rb +++ b/app/controllers/assignments_controller.rb @@ -22,4 +22,13 @@ def index end end + def bulk_modify_select + @action_items = authorize ActionItem.select("title, updated_at, category, id").order("updated_at DESC").all + end + + def bulk_modify_create + @action_item_id = params.fetch(:action_item_id) + @assignments = authorize Assignment.where(action_item_id: @action_item_id).order("updated_at DESC").includes(participant: :user) + end + end diff --git a/app/policies/action_item_policy.rb b/app/policies/action_item_policy.rb index 1790ec08..6a61ffcd 100644 --- a/app/policies/action_item_policy.rb +++ b/app/policies/action_item_policy.rb @@ -15,6 +15,14 @@ def show? staff? end + def bulk_modify_select? + staff? + end + + def bulk_modify_create? + staff? + end + private def staff? diff --git a/app/policies/assignment_policy.rb b/app/policies/assignment_policy.rb index 40648409..2680cd65 100644 --- a/app/policies/assignment_policy.rb +++ b/app/policies/assignment_policy.rb @@ -23,6 +23,10 @@ def complete? staff? or (user.participant? and (user.participant.id == resource.participant.id)) end + def bulk_modify_create? + staff? + end + class Scope < Scope def resolve if user.staff? diff --git a/app/views/assignments/bulk_modify_create.html.erb b/app/views/assignments/bulk_modify_create.html.erb new file mode 100644 index 00000000..8d294122 --- /dev/null +++ b/app/views/assignments/bulk_modify_create.html.erb @@ -0,0 +1,10 @@ + + +

<%= @action_item_id %>

+
    + <% for @assignment in @assignments -%> +
  • <%= @assignment.participant.user.first_name %> <%= @assignment.participant.user.last_name %> | <%= @assignment.updated_at %> | <%= @assignment.due_date %> | <%= @assignment.completed_participant %>
  • + <% end -%> +
+ + diff --git a/app/views/assignments/bulk_modify_select.html.erb b/app/views/assignments/bulk_modify_select.html.erb new file mode 100644 index 00000000..d1aa95a5 --- /dev/null +++ b/app/views/assignments/bulk_modify_select.html.erb @@ -0,0 +1,10 @@ + + +
    + <% for @action_item in @action_items -%> +
  • <%= @action_item.title %> | <%= @action_item.updated_at %> | <%= @action_item.category %> | <%= @action_item.id %>
  • + <% end -%> +
+

hiiie

+ + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 452d9d93..be342c70 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,7 +11,18 @@ mount RailsAdmin::Engine => '/admin', as: 'rails_admin' - resources :assignments, :studio_assessments, only: :index + resources :studio_assessments, only: :index + # resources :assignments, only: [] + resources :assignments, only: [] do + collection do + get '/', to: 'assignments#index' + match 'bulk-modify' => 'assignments#bulk_modify_select', :via => [:get] + match 'bulk-modify/:action_item_id' => 'assignments#bulk_modify_create', :via => [:get] + + # get 'bulk-modify', to: 'assignments#bulk_modify' + end + end + # get 'assignments/bulk_modify', action: :bulk_modify, controller: 'assignments' resources :staffs, only: [] do collection do From 8772ad0d70f2e798b82f79159766e06ba3f01b5b Mon Sep 17 00:00:00 2001 From: becky Date: Wed, 25 Nov 2020 14:40:14 -0800 Subject: [PATCH 5/5] Fixed PR review edits Added more backward compatability between TextField and RichText --- .../components/ActionItemCard/index.js | 5 +++-- .../components/ActionItemForm/index.js | 12 ----------- .../components/ActionItemModal/index.js | 20 +++++++++++++++++-- .../components/ViewMoreModal/index.js | 2 +- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/app/javascript/components/ActionItemCard/index.js b/app/javascript/components/ActionItemCard/index.js index b4103234..1336c9d7 100644 --- a/app/javascript/components/ActionItemCard/index.js +++ b/app/javascript/components/ActionItemCard/index.js @@ -221,8 +221,9 @@ function ActionItemCard({ alignItems="center" > - - {description[0] === '{' ? renderRichText(description) : description} + + {/* this makes the description backwards compatible TextField or RichText */} + {description[0] === '{' ? renderRichText(description) : description} diff --git a/app/javascript/components/ActionItemForm/index.js b/app/javascript/components/ActionItemForm/index.js index e788b3f1..bfdd6051 100644 --- a/app/javascript/components/ActionItemForm/index.js +++ b/app/javascript/components/ActionItemForm/index.js @@ -127,18 +127,6 @@ function ActionItemForm({ ]} /> - {/* setDescription(e)} - multiline - type="text" - margin="dense" - value={description} - required - error={failedSubmit && !description} - rows={2} - /> */} Due Date (Optional) diff --git a/app/javascript/components/ActionItemModal/index.js b/app/javascript/components/ActionItemModal/index.js index 911204c1..ff0fc94f 100644 --- a/app/javascript/components/ActionItemModal/index.js +++ b/app/javascript/components/ActionItemModal/index.js @@ -169,7 +169,9 @@ class ActionItemModal extends React.Component { Description
- + /> ):( + )}
diff --git a/app/javascript/components/ViewMoreModal/index.js b/app/javascript/components/ViewMoreModal/index.js index 4950370c..b7e27370 100644 --- a/app/javascript/components/ViewMoreModal/index.js +++ b/app/javascript/components/ViewMoreModal/index.js @@ -98,7 +98,7 @@ function ViewMoreModal({
- {renderRichText(description)} + {description[0] === '{' ? renderRichText(description) : description}