Skip to content

Commit

Permalink
Add missing expands, and props
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás Castillo <[email protected]>
  • Loading branch information
tomrndom committed Dec 18, 2024
1 parent 7ae3823 commit 1ace4cc
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 88 deletions.
2 changes: 1 addition & 1 deletion src/actions/event-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ export const getEvent = (eventId) => async (dispatch, getState) => {
const params = {
access_token: accessToken,
expand:
"creator,speakers,moderator,sponsors,groups,type,type.allowed_media_upload_types,type.allowed_media_upload_types.type, slides, links, videos, media_uploads, tags, media_uploads.media_upload_type, media_uploads.media_upload_type.type,extra_questions,selection_plan,selection_plan.extra_questions, selection_plan.extra_questions.values,selection_plan.track_chair_rating_types,selection_plan.track_chair_rating_types.score_types,created_by,track_chair_scores_avg.ranking_type,actions,allowed_ticket_types",
"creator,speakers,moderator,sponsors,groups,type,type.allowed_media_upload_types,type.allowed_media_upload_types.type, slides, links, videos, media_uploads, tags, media_uploads.media_upload_type, media_uploads.media_upload_type.type,extra_questions,selection_plan,selection_plan.extra_questions, selection_plan.extra_questions.values,selection_plan.track_chair_rating_types,selection_plan.track_chair_rating_types.score_types,created_by,track_chair_scores_avg.ranking_type,actions,allowed_ticket_types,allowed_badge_features_types",
fields: "allowed_ticket_types.id,allowed_ticket_types.name"
};

Expand Down
1 change: 1 addition & 0 deletions src/actions/summit-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const getSummitById = (summitId) => async (dispatch) => {
"selection_plans," +
"ticket_types," +
"badge_types," +
"badge_features," +
"badge_features_types," +
"badge_access_level_types," +
"badge_view_types," +
Expand Down
6 changes: 3 additions & 3 deletions src/components/forms/extra-question-form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,11 @@ class ExtraQuestionForm extends React.Component {
</label>
<Dropdown
id="allowed_badge_features_types"
clearable
isMulti
value={entity.allowed_badge_features_types}
onChange={this.handleChange}
options={badge_features_ddl}
onChange={this.handleChange}
clearable
isMulti
/>
</div>
</>
Expand Down
1 change: 1 addition & 0 deletions src/pages/sponsors/edit-sponsor-extra-question-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function EditSponsorExtraQuestionPage({
<hr />
{currentSummit && (
<ExtraQuestionForm
currentSummit={currentSummit}
shouldAllowSubRules={false}
shouldShowUsage={false}
shouldShowPrintable={false}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/summits/edit-selection-plan-extra-question-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class EditSelectionPlanExtraQuestionPage extends React.Component {
this.props.saveSelectionPlanExtraQuestion(selectionPlanId, entity);
}

componentDidUpdate(prevProps, prevState, snapshot) {
componentDidUpdate(prevProps) {
const oldId = prevProps.match.params.extra_question_id;
const newId = this.props.match.params.extra_question_id;
const selectionPlanId = this.props.currentSelectionPlan.id;
Expand Down Expand Up @@ -132,6 +132,7 @@ class EditSelectionPlanExtraQuestionPage extends React.Component {
<hr />
{currentSummit && (
<ExtraQuestionForm
currentSummit={currentSummit}
shouldAllowSubRules={false}
shouldShowUsage={false}
shouldShowPrintable={false}
Expand Down
142 changes: 59 additions & 83 deletions src/reducers/summits/selection-plan-extra-question-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
* */

import { VALIDATE } from "openstack-uicore-foundation/lib/utils/actions";
import { LOGOUT_USER } from "openstack-uicore-foundation/lib/security/actions";

import {
RESET_SELECTION_PLAN_EXTRA_QUESTION_FORM,
Expand All @@ -23,8 +26,6 @@ import {
SELECTION_PLAN_EXTRA_QUESTION_VALUE_UPDATED
} from "../../actions/selection-plan-actions";

import { VALIDATE } from "openstack-uicore-foundation/lib/utils/actions";
import { LOGOUT_USER } from "openstack-uicore-foundation/lib/security/actions";
import { SET_CURRENT_SUMMIT } from "../../actions/summit-actions";

export const DEFAULT_ENTITY = {
Expand All @@ -35,7 +36,8 @@ export const DEFAULT_ENTITY = {
mandatory: false,
placeholder: "",
values: [],
is_editable: true
is_editable: true,
allowed_badge_features_types: []
};

const DEFAULT_STATE = {
Expand All @@ -48,102 +50,76 @@ const selectionPlanExtraQuestionReducer = (state = DEFAULT_STATE, action) => {
const { type, payload } = action;
switch (type) {
case LOGOUT_USER:
{
// we need this in case the token expired while editing the form
if (payload.hasOwnProperty("persistStore")) {
return state;
} else {
return { ...state, entity: { ...DEFAULT_ENTITY }, errors: {} };
}
// we need this in case the token expired while editing the form
if (payload.hasOwnProperty("persistStore")) {
return state;
}
break;
return { ...state, entity: { ...DEFAULT_ENTITY }, errors: {} };
case SET_CURRENT_SUMMIT:
case RESET_SELECTION_PLAN_EXTRA_QUESTION_FORM:
{
return { ...state, entity: { ...DEFAULT_ENTITY }, errors: {} };
}
break;
case RECEIVE_SELECTION_PLAN_EXTRA_QUESTION_META:
{
let allClasses = payload.response;
return { ...state, entity: { ...DEFAULT_ENTITY }, errors: {} };
case RECEIVE_SELECTION_PLAN_EXTRA_QUESTION_META: {
const allClasses = payload.response;

return { ...state, allClasses: allClasses };
}
break;
return { ...state, allClasses };
}
case UPDATE_SELECTION_PLAN_EXTRA_QUESTION:
{
return { ...state, entity: { ...payload }, errors: {} };
}
break;
return { ...state, entity: { ...payload }, errors: {} };
case SELECTION_PLAN_EXTRA_QUESTION_ADDED:
case RECEIVE_SELECTION_PLAN_EXTRA_QUESTION:
{
let entity = { ...payload.response };
case RECEIVE_SELECTION_PLAN_EXTRA_QUESTION: {
const entity = { ...payload.response };

for (var key in entity) {
if (entity.hasOwnProperty(key)) {
entity[key] = entity[key] == null ? "" : entity[key];
}
for (const key in entity) {
if (entity.hasOwnProperty(key)) {
entity[key] = entity[key] == null ? "" : entity[key];
}

return { ...state, entity: { ...DEFAULT_ENTITY, ...entity } };
}
break;

return { ...state, entity: { ...DEFAULT_ENTITY, ...entity } };
}
case SELECTION_PLAN_EXTRA_QUESTION_UPDATED:
{
return state;
return state;
case SELECTION_PLAN_EXTRA_QUESTION_VALUE_ADDED: {
const entity = { ...payload.response };
let values = [...state.entity.values];
if (entity.is_default) {
// reset all other values
values = values.map((v) => ({ ...v, is_default: false }));
}
break;
case SELECTION_PLAN_EXTRA_QUESTION_VALUE_ADDED:
{
let entity = { ...payload.response };
let values = [...state.entity.values];
if (entity.is_default) {
// reset all other values
values = values.map((v) => ({ ...v, is_default: false }));
}

return {
...state,
entity: { ...state.entity, values: [...values, entity] }
};
return {
...state,
entity: { ...state.entity, values: [...values, entity] }
};
}
case SELECTION_PLAN_EXTRA_QUESTION_VALUE_UPDATED: {
const entity = { ...payload.response };
let values_tmp = state.entity.values.filter((v) => v.id !== entity.id);
if (entity.is_default) {
// reset all other values
values_tmp = values_tmp.map((v) => ({ ...v, is_default: false }));
}
break;
case SELECTION_PLAN_EXTRA_QUESTION_VALUE_UPDATED:
{
let entity = { ...payload.response };
let values_tmp = state.entity.values.filter((v) => v.id !== entity.id);
if (entity.is_default) {
// reset all other values
values_tmp = values_tmp.map((v) => ({ ...v, is_default: false }));
}

let values = [...values_tmp, entity];
const values = [...values_tmp, entity];

values.sort((a, b) =>
a.order > b.order ? 1 : a.order < b.order ? -1 : 0
);
values.sort((a, b) =>
a.order > b.order ? 1 : a.order < b.order ? -1 : 0
);

return { ...state, entity: { ...state.entity, values: values } };
}
break;
case SELECTION_PLAN_EXTRA_QUESTION_VALUE_DELETED:
{
let { valueId } = payload;
return {
...state,
entity: {
...state.entity,
values: state.entity.values.filter((v) => v.id !== valueId)
}
};
}
break;
return { ...state, entity: { ...state.entity, values } };
}
case SELECTION_PLAN_EXTRA_QUESTION_VALUE_DELETED: {
const { valueId } = payload;
return {
...state,
entity: {
...state.entity,
values: state.entity.values.filter((v) => v.id !== valueId)
}
};
}
case VALIDATE:
{
return { ...state, errors: payload.errors };
}
break;
return { ...state, errors: payload.errors };
default:
return state;
}
Expand Down

0 comments on commit 1ace4cc

Please sign in to comment.