fix: Dispatch update_order always. Handle perm-wise action in backend
- 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
This commit is contained in:
parent
70fac30e77
commit
ef75e0f9b8
2 changed files with 5 additions and 9 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue