-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #244 from scdanieli/lan-117-create-stocking-targets
- Loading branch information
Showing
3 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 47 additions & 1 deletion
48
landa/water_body_management/doctype/stocking_measure/stocking_measure_list.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,56 @@ | ||
frappe.listview_settings["Stocking Measure"] = { | ||
get_indicator: function (doc) { | ||
var status_color = { | ||
const status_color = { | ||
Draft: "red", | ||
"In Progress": "blue", | ||
Completed: "green", | ||
}; | ||
|
||
return [__(doc.status), status_color[doc.status], "status,=," + doc.status]; | ||
}, | ||
refresh: function (doc) { | ||
doc.page.add_actions_menu_item( | ||
__("Create Stocking Targets"), | ||
() => showCreateStockingTargetsDialog(), | ||
false | ||
); // Needs to be in refresh, otherwise it won't work in the Report View | ||
}, | ||
}; | ||
|
||
function showCreateStockingTargetsDialog() { | ||
const dialog = new frappe.ui.Dialog({ | ||
title: __("Create Stocking Targets"), | ||
fields: [ | ||
{ | ||
label: __("Year"), | ||
fieldname: "year", | ||
fieldtype: "Int", | ||
reqd: 1, | ||
default: landa.utils.get_default_year(), | ||
description: __( | ||
"Based on your selection, Stocking Targets are created accordingly for the specified year." | ||
), | ||
}, | ||
], | ||
size: "small", | ||
primary_action_label: __("Create"), | ||
primary_action(values) { | ||
const selected_measures = cur_list.get_checked_items(true); | ||
|
||
frappe.call({ | ||
method: "landa.water_body_management.doctype.stocking_measure.stocking_measure.create_stocking_targets", | ||
args: { | ||
stocking_measure_names: selected_measures, | ||
year: values.year, | ||
}, | ||
callback: function (response) { | ||
frappe.set_route("List", "Stocking Target", "List"); | ||
}, | ||
}); | ||
|
||
dialog.hide(); | ||
}, | ||
}); | ||
|
||
dialog.show(); | ||
} |