Skip to content

Commit

Permalink
fix: Dispatch update_order always. Handle perm-wise action in backend
Browse files Browse the repository at this point in the history
- Currently, `update_order` is also responsible for fetching fresh column order from db as well updating card order
- In the .py file, return board doc if no write permission as that is used to render thr right columns order
- Without it, stale order (before moving columns) is restored as there is no db call getting columns that were last stored

(cherry picked from commit ef75e0f)
  • Loading branch information
marination authored and mergify[bot] committed Mar 16, 2023
1 parent a9b5f04 commit e5c5cdb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 4 additions & 2 deletions frappe/desk/doctype/kanban_board/kanban_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,15 @@ def update_order(board_name, order):
"""Save the order of cards in columns"""
board = frappe.get_doc("Kanban Board", board_name)
doctype = board.reference_doctype
updated_cards = []

frappe.has_permission(doctype, "write", throw=True)
if not frappe.has_permission(doctype, "write"):
# Return board data from db
return board, updated_cards

fieldname = board.field_name
order_dict = json.loads(order)

updated_cards = []
for col_name, cards in order_dict.items():
for card in cards:
column = frappe.get_value(doctype, {"name": card}, fieldname)
Expand Down
8 changes: 1 addition & 7 deletions frappe/public/js/frappe/views/kanban/kanban_board.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,7 @@ frappe.provide("frappe.views");
return state.empty_state;
}, show_empty_state);

if (frappe.model.can_write(store.state.doctype)) {
// Check for reference doctype access before trying to modify it's value
store.dispatch("update_order");
} else {
// Render columns without state change
make_columns();
}
store.dispatch("update_order");
}

function prepare() {
Expand Down

0 comments on commit e5c5cdb

Please sign in to comment.