Skip to content

Commit

Permalink
chore: clean up js
Browse files Browse the repository at this point in the history
  • Loading branch information
MyPyDavid committed Dec 11, 2023
1 parent ec9c5ee commit 8b60c37
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
13 changes: 5 additions & 8 deletions rdmo/management/assets/js/actions/elementActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,11 @@ export function fetchElements(elementType) {
action = (dispatch) => TasksApi.fetchTasks(true)
.then(tasks => dispatch(fetchElementsSuccess({ tasks })))
break
// TODO add the action join_site here?

case 'views':
action = (dispatch) => ViewsApi.fetchViews(true)
.then(views => dispatch(fetchElementsSuccess({ views })))
break
// TODO add the action join_site here?
}

return dispatch(action)
Expand Down Expand Up @@ -316,7 +314,6 @@ export function fetchElementError(error) {

export function storeElement(elementType, element, back, elementAction=null) {
return function(dispatch, getState) {
// updateLocation(getState().config.baseUrl, elementType, element.id, elementAction)

dispatch(storeElementInit(element, elementAction))

Expand Down Expand Up @@ -539,13 +536,13 @@ export function createElementError(error) {

// delete element

export function deleteElement(elementType, element, elementAction=null) {
export function deleteElement(elementType, element) {
return function(dispatch) {
dispatch(deleteElementInit(element, elementAction))
dispatch(deleteElementInit(element))

let action
switch (elementType) {
case 'catalogs' :
case 'catalogs':
action = () => QuestionsApi.deleteCatalog(element)
break
case 'sections':
Expand Down Expand Up @@ -599,8 +596,8 @@ export function deleteElement(elementType, element, elementAction=null) {
}
}

export function deleteElementInit(element, elementAction) {
return {type: 'elements/deleteElementInit', element, elementAction}
export function deleteElementInit(element) {
return {type: 'elements/deleteElementInit', element}
}

export function deleteElementSuccess(element) {
Expand Down
7 changes: 2 additions & 5 deletions rdmo/management/assets/js/api/QuestionsApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class QuestionsApi extends BaseApi {
}

static storeCatalog(catalog, action) {
console.log('storeCatalog', catalog, action)
if (isNil(catalog.id)) {
return this.post('/api/v1/questions/catalogs/', catalog)
} else {
Expand All @@ -30,10 +29,8 @@ class QuestionsApi extends BaseApi {
}
}

static deleteCatalog(catalog, action) {
let url = `/api/v1/questions/catalogs/${catalog.id}/`
if (action == 'join_site') url += 'join_site/'
return this.delete(url)
static deleteCatalog(catalog) {
return this.delete(`/api/v1/questions/catalogs/${catalog.id}/`)
}

static fetchSections(action) {
Expand Down

0 comments on commit 8b60c37

Please sign in to comment.