From decd2a5196e3c09d09528d7d173cf7e983b7ac67 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Sat, 9 Apr 2022 07:50:50 +0000 Subject: [PATCH] temp cnt commented --- smart_service/fixtures/client_script.json | 4 ++-- smart_service/transactions/doctype/procedure/procedure.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/smart_service/fixtures/client_script.json b/smart_service/fixtures/client_script.json index 8290798..c793399 100644 --- a/smart_service/fixtures/client_script.json +++ b/smart_service/fixtures/client_script.json @@ -186,12 +186,12 @@ "doctype": "Client Script", "dt": "Procedure", "enabled": 1, - "modified": "2022-04-08 22:15:25.080557", + "modified": "2022-04-08 22:42:54.085111", "name": "Procedure-Form", "parent": null, "parentfield": null, "parenttype": null, - "script": "var trigger = true;\n\ncur_frm.fields_dict['variant_mapping'].get_query = function(doc, cdt, cdn) {\n return {query:\"smart_service.transactions.doctype.procedure.procedure.variant\",};\n};\ncur_frm.fields_dict['sub_systems'].get_query = function(doc, cdt, cdn) {\n return {query:\"smart_service.transactions.doctype.procedure.procedure.sub_systems\",};\n};\n\nfrappe.ui.form.on('Procedure', {\n onload: function (frm) {\n if (frm.doc.workflow_state == 'Publish Ready'){\n frm.set_read_only();\n }\n var html = \"\";\n html = html + \"\" ;\n html = html + \"\" ;\n html = html + \"\" ;\n html = html + \"\" ;\n html = html + \"\" ;\n html = html + \"\" ;\n html = html + \"
HTML Tag\" + \"How to tag <...>\" + \"Result
Bold\" + \"<b>Using a 10 mm socket.</b>\" + \"Using a 10 mm socket.
Break\" + \"Using a <br>10 mm socket.\" + \"Using a
10 mm socket.
Italic\" + \"<i>Using a 10 mm socket.</i>\" + \"Using a 10 mm socket.
Unordered List\" + \"<ul><li>Using a 10 mm socket.</li><li>the steering fluid line.</li></ul>\" + \"
  • Using a 10 mm socket.
  • the steering fluid line.
Ordered List\" + \"<ol><li>Using a 10 mm socket.</li><li>the steering fluid line.</li></ol>\" + \"
  1. Using a 10 mm socket.
  2. the steering fluid line.
\";\n $(frm.fields_dict.html_reference.wrapper).html(html);\n },\n procedure_details_on_form_rendered: function(frm,cdt,cdn){\n\t\tcur_frm.cscript.highlight_row(frm.open_grid_row());\n\t\t\n\t},\n validate: function(frm){\n \n var regex = /[@#$%^*+\\\\[\\]{}`~:\\\\|\\?]+/;\n if(frm.doc.procedure_details){\n for (var i=0;iContent: Only letters, numbers and - ,'<>_()!=/; are allowed.\"));\n frappe.validated = false;\n }\n } \n }\n }\n \n frm.doc.procedure_filter = \"All\";\n if(frm.doc.procedure_filter == \"All\"){\n frm.get_field('procedure_details').grid.static_rows = false;\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').show();\n });\n }\n\n frm.refresh();\n },\n refresh: function (frm) {\n select_row(frm);\n if(frm.doc.procedure_filter == \"All\"){\n frm.get_field('procedure_details').grid.static_rows = false;\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').show();\n });\n }\n var previous_procedure_name = \"\";\n var previous_step_name = \"\";\n $(\"select[data-fieldname='procedure_filter']\").empty();\n $(\"select[data-fieldname='procedure_filter']\").append(new Option(\"All\", \"All\"));\n $(\"select[data-fieldname='step_filter']\").empty();\n $(\"select[data-fieldname='step_filter']\").append(new Option(\"All\", \"All\"));\n cur_frm.doc.procedure_filter = \"All\";\n cur_frm.doc.step_filter = \"All\";\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n if (row.doc.step_name){\n fn_addSteptolist(row.doc.step_name);\n }\n\n if (row.doc.procedure_name){\n fn_addProceduretolist(row.doc.procedure_name);\n }\n \n if (row.doc.procedure_name == previous_procedure_name){\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').find('div.col[data-fieldname=\"procedure_name\"]').find('a[data-doctype=\"Procedure Name\"]').css({'color': '#EDEDED'});\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').css({'background-color': '#FFFFFF'});\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').css({'border-bottom': '1px Solid #ebeef0'});\n }else{\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').find('div.col[data-fieldname=\"procedure_name\"]').find('a[data-doctype=\"Procedure Name\"]').css({'color': '#000000'});\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').css({'background-color': '#EDEDED'});\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').css({'border-bottom': '1px Solid #7b7c7c'});\n }\n previous_procedure_name = row.doc.procedure_name;\n \n \n if (row.doc.step_name == previous_step_name){\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').find('div.col[data-fieldname=\"step_name\"]').find('a[data-doctype=\"Procedure Step Name\"]').css({'color': '#DFDFDF'});\n }else{\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').find('div.col[data-fieldname=\"step_name\"]').find('a[data-doctype=\"Procedure Step Name\"]').css({'color': '#000000'});\n }\n previous_step_name = row.doc.step_name;\n let id = row.doc.idx;\n\n });\n\n if (frm.doc.workflow_state == \"Publish Ready\" && frappe.user_roles.indexOf(\"_Admin\") > 0){\n frm.add_custom_button(__('Revoke Publish'), function(){\n //get all system mapping with the procedure linked\n frappe.db.get_list('System Mapping_Sub System', {\n fields: ['parent', 'procedure', 'procedure_status'],\n filters: {\n procedure: frm.doc.name\n }\n }).then(records => {\n var html = \"

\";\n $.each(records, function(index, row){\n html = html + \"\" +\"\";\n });\n html = html + \"
\" + row.parent + \"\" + row.procedure + \"
\";\n frappe.warn('Are you sure you want to Revoke?',\n 'Since there are System Mappings attached to it!!! ' + html,\n () => {\n frm.set_value(\"workflow_state\",\"Draft\");\n frm.save();\n // action to perform if Continue is selected\n },\n 'Continue', false // Sets dialog as minimizable\n );\n });\n });\n }\n },\n \n procedure_filter: function (frm) {\n //if (!trigger){ trigger = true; return;}\n select_row(frm);\n if (frm.doc.procedure_filter ==\"All\"){\n frm.doc.step_filter = \"All\";\n cur_frm.refresh_field('step_filter');\n frm.get_field('procedure_details').grid.static_rows = false;\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').show();\n });\n } else {\n frm.get_field('procedure_details').grid.static_rows = false;\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n if (row.doc.procedure_name != frm.doc.procedure_filter){\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').hide();\n } else {\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').show();\n }\n });\n }\n //frm.refresh();\n \n //Filtered by as per step filter\n if(frm.doc.name && frm.is_new() == undefined){\n $(\"select[data-fieldname='step_filter']\").empty();\n\t\t$(\"select[data-fieldname='step_filter']\").append(new Option(\"All\", \"All\"));\n\t\tvar x = frappe.db.get_list('Procedure_Details', {\n\t\t\tfields: ['step_name'],\n\t\t\tfilters: {\n\t\t\t\tprocedure_name: frm.doc.procedure_filter,\n\t\t\t\tparent: frm.doc.name\n\t\t\t}\n\t\t\n\t\t}).then(steps => {\n\t\tvar child;\n\t\t\t$.each(steps, function(index, row){\n\t\t\t\tfn_steplist(row.step_name);\n\t\t\t})\n\t\t})\n }\n \n $(\"select[data-fieldname='step_filter']\").empty();\n\t\t$(\"select[data-fieldname='step_filter']\").append(new Option(\"All\", \"All\"));\n for(var i = 0;i {\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').show();\n });\n } else {\n frm.get_field('procedure_details').grid.static_rows = false;\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n if (row.doc.procedure_name == frm.doc.procedure_filter && row.doc.step_name == frm.doc.step_filter){\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').show();\n }else if(row.doc.procedure_name == frm.doc.procedure_filter && frm.doc.step_filter == \"All\"){\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').show();\n \n }else {\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').hide();\n }\n });\n }\n },\n \n before_workflow_action: (frm) => {\n if ((frm.doc.workflow_state == 'Review Pending' || frm.doc.workflow_state == 'Publish Ready') && (frm.selected_workflow_action == 'Revoke')){\n //frappe.throw(\"Any connected Publish Planning will get affected. Please check!\");\n frappe.call({\n \"method\": \"smart_service.transactions.doctype.procedure.procedure.get_publish_details\",\n \"args\": {\n \"procedure_name\": frm.doc.name,\n \"status\":'Published1',\n \t},\n \tfreeze: true,\n \tasync:false,\n \tcallback:function(r){\n \t var publish_list = r.message;\n \t if (publish_list.length){\n \t var html = \"This Procedure is linked with the following Publish Docs:
    \";\n \t publish_list.forEach((array_row) => {\n \t html = html + \"
  1. \" + array_row + \"
  2. \";\n \t });\n \t html = html + \"
\";\n frappe.msgprint({\n title: __('Notification'),\n indicator: 'green',\n message: __(html)\n });\n \t }\n \t}\n });\n }\n },\n mat:function(frm){\n if (!frm.is_new()){\n frappe.msgprint({\n title: __('Notification'),\n indicator: 'green',\n message: __('Updating MAT will impact its connected System Mapping and so with Kilometer Mapping. Please Check!')\n });\n }\n }\n});\n\nfrappe.ui.form.on('Procedure_Details', {\n procedure_name: function (frm,cdt,cdn) {\n var title = frm.doc.procedure_filter;\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n let value = row.doc.procedure_name;\n if (value)\n if ($(\"select[data-fieldname='procedure_filter'] option[value='\" + value + \"']\").length === 0){\n $(\"select[data-fieldname='procedure_filter']\").append(new Option(value, value));\n }\n \n });\n frm.doc.procedure_filter = title;\n // frm.refresh();\n },\n step_name: function (frm,cdt,cdn) {\n // frm.refresh();\n var filtered_step = frm.doc.step_filter;\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n let value = row.doc.step_name;\n if (value && frm.doc.procedure_filter == \"All\"){\n if ($(\"select[data-fieldname='step_filter'] option[value='\" + value + \"']\").length === 0){\n $(\"select[data-fieldname='step_filter']\").append(new Option(value, value));\n }\n }\n if(value && frm.doc.procedure_filter == row.doc.procedure_name){\n fn_stepfilter(row.doc.step_name)\n }\n });\n frm.doc.step_filter = filtered_step;\n\n },\n /*content_type: function (frm,cdt,cdn) {\n var df;\n let d = locals[cdt][cdn];\n var id = d.idx;\n id = id-1;\n let row = frm.fields_dict.procedure_details.grid.grid_rows[id];\n if (d.content_type == 'Link'){\n let d = new frappe.ui.Dialog({\n title: 'Select a Procedure',\n fields:[\n {\n label: 'Procedure',\n fieldname: 'procedure_map',\n fieldtype: 'Link',\n options:'Procedure'\n }\n ],\n primary_action_label: 'Select',\n primary_action(values) {\n // row.doc.content = values.procedure_map;\n var url = window.location.host;\n var content = values.procedure_map;\n row.doc.temp_cnt = values.procedure_map;\n row.doc.content = content.link(\"http://\" + url + \"/app/procedure/\" + content);\n // row.doc.content = '' + content + '';\n d.hide();\n frm.refresh();\n }\n });\n d.show();\n } else {\n d.content = d.content1;\n }\n },*/\n content_type: function (frm,cdt,cdn) {\n var df;\n let d = locals[cdt][cdn];\n var id = d.idx;\n id = id-1;\n let row = frm.fields_dict.procedure_details.grid.grid_rows[id];\n if(d.content_type != \"Link\"){\n d.system_id = '';\n cur_frm.refresh_fields();\n }\n if (d.content_type == 'Link'){\n let d = new frappe.ui.Dialog({\n title: 'Select a Procedure',\n fields:[\n {\n label: 'Variant Mapping',\n fieldname: 'variant_mapping',\n fieldtype: 'Link',\n options:'Variant Mapping',\n get_query: function() {\n return {\n \"query\": \"smart_service.transactions.doctype.procedure.procedure.get_variant\",\n \"filters\": {\n variant_mapping: frm.doc.variant_mapping\n \n }\n };\n },\n onchange: function() {\n cur_dialog.set_value(\"systems\", \"\");\n cur_dialog.set_value(\"sub_systems\", \"\");\n cur_dialog.set_value(\"procedure\", \"\");\n d.refresh()\n },\n },\n {\n label: 'Systems',\n fieldname: 'systems',\n fieldtype: 'Link',\n options:'Systems',\n get_query: function() {\n return {\n \"query\": \"smart_service.transactions.doctype.procedure.procedure.get_systems\",\n \"filters\": {\n variant_mapping: d.get_values()['variant_mapping'],\n language: frm.doc.language\n }\n };\n },\n onchange: function() {\n cur_dialog.set_value(\"sub_systems\", \"\");\n cur_dialog.set_value(\"procedure\",\"\");\n d.refresh()\n if (d.get_values()[\"systems\"]){\n frappe.call({\n method: \"smart_service.transactions.doctype.procedure.procedure.get_systemid\",\n args: {\n systems: d.get_values()[\"systems\"],\n },\n callback: function(r) {\n if(r.message) {\n cur_dialog.set_value(\"system_id\",r.message);\n d.refresh\n }\n }\n })\n }\n \n },\n },\n {\n label: 'Sub Systems',\n fieldname: 'sub_systems',\n fieldtype: 'Link',\n options:'Sub Systems',\n get_query: function() { \n \n return {\n \"query\": \"smart_service.transactions.doctype.procedure.procedure.get_subsystems\",\n \"filters\": {\n variant_mapping: d.get_values()['variant_mapping'],\n systems: d.get_values()['systems'],\n language: frm.doc.language\n }\n };\n },\n onchange: function() {\n cur_dialog.set_value(\"procedure\",\"\");\n d.refresh()\n if (d.get_values()['sub_systems']){\n frappe.call({\n method: \"smart_service.transactions.doctype.procedure.procedure.get_subsystemid\",\n args: {\n systems: d.get_values()['sub_systems'],\n },\n callback: function(r) {\n if(r.message) {\n cur_dialog.set_value(\"subsystem_id\",r.message);\n d.refresh\n }\n \n }\n })\n }\n if (d.get_values()['sub_systems']){\n frappe.call({\n method: \"smart_service.transactions.doctype.procedure.procedure.get_procedures\",\n args: {\n variant_mapping: d.get_values()['variant_mapping'],\n systems: d.get_values()['systems'],\n sub_systems: d.get_values()['sub_systems'],\n language: frm.doc.language\n },\n callback: function(r) {\n if(r.message) {\n cur_dialog.set_value(\"procedure\",r.message);\n d.refresh();\n }\n }\n \n \n })\n }\n },\n },\n {\n label: 'Procedure',\n fieldname: 'procedure',\n fieldtype: 'Link',\n options:'Procedure',\n read_only: 1,\n },\n {\n label: 'System Myid',\n fieldname: 'system_id',\n fieldtype: 'Data',\n hidden: 1,\n \n },\n {\n label: 'Sub System Myid',\n fieldname: 'subsystem_id',\n fieldtype: 'Data',\n hidden: 1,\n \n },\n ],\n primary_action_label: 'Select',\n primary_action(values) {\n var url = window.location.host;\n var content = values.procedure;\n row.doc.temp_cnt = values.procedure;\n row.doc.system_id = values.variant_mapping + ',' + values.system_id + ',' + values.subsystem_id;\n // row.doc.content = content.link(\"http://\" + url + \"/app/procedure/\" + content);\n row.doc.content = '' + content + '';\n d.hide();\n frm.refresh();\n cur_frm.refresh_fields('procedure_details');\n }\n });\n d.show();\n } else {\n d.content = d.temp_cnt;\n \n }\n},\n procedure_details_move: function (frm,cdt,cdn) {\n frm.refresh();\n },\n procedure_details_remove: function(frm,cdt,cdn){\n frm.doc.procedure_filter = \"All\";\n frm.doc.step_filter = \"All\";\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n if (row.doc.procedure_name){\n fn_addProceduretolist(row.doc.procedure_name);\n }\n })\n frm.refresh_field('procedure_details');\n cur_frm.refresh_fields();\n frm.refresh();\n },\n procedure_details_add: function(frm,cdt,cdn) {\n select_row(frm);\n \tvar d = locals[cdt][cdn];\n \tvar id = d.idx;\n id = id-1;\n var row = frm.fields_dict.procedure_details.grid.grid_rows[id];\n var prevrow = frm.fields_dict.procedure_details.grid.grid_rows[id-1];\n if (frm.doc.procedure_filter == \"All\"){\n if (prevrow !== undefined) {\n row.doc.procedure_name = prevrow.doc.procedure_name;\n row.doc.step_name = prevrow.doc.step_name;\n }\n }else{\n row.doc.procedure_name = frm.doc.procedure_filter;\n // row.doc.step_name = prevrow.doc.step_name;\n }\n if (frm.doc.step_filter == \"All\" && frm.doc.procedure_filter == \"All\"){\n if (prevrow !== undefined) {\n row.doc.procedure_name = prevrow.doc.procedure_name;\n row.doc.step_name = prevrow.doc.step_name;\n }\n }\n else if(frm.doc.step_filter == \"All\" && frm.doc.procedure_filter != \"All\"){\n row.doc.procedure_name = frm.doc.procedure_filter;\n // row.doc.step_name = prevrow.doc.step_name;\n }else{\n row.doc.procedure_name = frm.doc.procedure_filter;\n row.doc.step_name = frm.doc.step_filter;\n }\n\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n if (row.doc.step_name && row.doc.procedure_name == frm.doc.procedure_filter){\n fn_addSteptolist(row.doc.step_name);\n }\n })\n\n refresh_field(\"procedure_filter\");\n refresh_field(\"step_filter\");\n },\n});\n\nfunction fn_addProceduretolist(value){\n if (value === \"\") {return;}\n if ($(\"select[data-fieldname='procedure_filter'] option[value='\" + value + \"']\").length === 0){\n $(\"select[data-fieldname='procedure_filter']\").append(new Option(value, value));\n }\n}\nfunction fn_addSteptolist(value){\n if (value === \"\") {return;}\n if ($(\"select[data-fieldname='step_filter'] option[value='\" + value + \"']\").length === 0){\n $(\"select[data-fieldname='step_filter']\").append(new Option(value, value));\n }\n}\n\nfunction fn_steplist(value){\n\tif (value === \"\") {return;}\n\t\tif ($(\"select[data-fieldname='step_filter'] option[value='\" + value + \"']\").length === 0){\n\t\t\t$(\"select[data-fieldname='step_filter']\").append(new Option(value, value));\n\t\t}\n}\n\nfunction fn_stepfilter(value){\n\tif (value === \"\") {return;}\n\t \n\t\tif ($(\"select[data-fieldname='step_filter'] option[value='\" + value + \"']\").length === 0){\n\t\t\t$(\"select[data-fieldname='step_filter']\").append(new Option(value, value));\n\t\t}\n}\nfunction select_row(frm){\n if(frm.doc.procedure_filter != \"All\"){\n\t$('div[data-fieldname=procedure_details]').find('div[class=form-grid]').find('div[class=grid-heading-row]').find('div[class=\"row-index sortable-handle col col-xs-1\"]').find('input[class=\"grid-row-check pull-left\"]').css({'visibility': 'hidden'});\n\t}\n\telse{\n\t$('div[data-fieldname=procedure_details]').find('div[class=form-grid]').find('div[class=grid-heading-row]').find('div[class=\"row-index sortable-handle col col-xs-1\"]').find('input[class=\"grid-row-check pull-left\"]').css({'visibility': 'visible'});\n\n\t}\n\n}\ncur_frm.cscript.highlight_row = function(grid_row){\n\tvar idx = grid_row.doc.idx;\n\tcur_frm.fields_dict[\"procedure_details\"].$wrapper.find('.grid-body .rows').find(\".grid-row\").each(function(i, item) {\n\tlet d = locals[cur_frm.fields_dict[\"procedure_details\"].grid.doctype][$(item).attr('data-name')];\n\tif(d[\"idx\"] === idx){\n\t\tgrid_row.toggle_editable_row(true);\n\t}\n\t});\n}\n\n", + "script": "var trigger = true;\n\ncur_frm.fields_dict['variant_mapping'].get_query = function(doc, cdt, cdn) {\n return {query:\"smart_service.transactions.doctype.procedure.procedure.variant\",};\n};\ncur_frm.fields_dict['sub_systems'].get_query = function(doc, cdt, cdn) {\n return {query:\"smart_service.transactions.doctype.procedure.procedure.sub_systems\",};\n};\n\nfrappe.ui.form.on('Procedure', {\n onload: function (frm) {\n if (frm.doc.workflow_state == 'Publish Ready'){\n frm.set_read_only();\n }\n var html = \"\";\n html = html + \"\" ;\n html = html + \"\" ;\n html = html + \"\" ;\n html = html + \"\" ;\n html = html + \"\" ;\n html = html + \"\" ;\n html = html + \"
HTML Tag\" + \"How to tag <...>\" + \"Result
Bold\" + \"<b>Using a 10 mm socket.</b>\" + \"Using a 10 mm socket.
Break\" + \"Using a <br>10 mm socket.\" + \"Using a
10 mm socket.
Italic\" + \"<i>Using a 10 mm socket.</i>\" + \"Using a 10 mm socket.
Unordered List\" + \"<ul><li>Using a 10 mm socket.</li><li>the steering fluid line.</li></ul>\" + \"
  • Using a 10 mm socket.
  • the steering fluid line.
Ordered List\" + \"<ol><li>Using a 10 mm socket.</li><li>the steering fluid line.</li></ol>\" + \"
  1. Using a 10 mm socket.
  2. the steering fluid line.
\";\n $(frm.fields_dict.html_reference.wrapper).html(html);\n },\n procedure_details_on_form_rendered: function(frm,cdt,cdn){\n\t\tcur_frm.cscript.highlight_row(frm.open_grid_row());\n\t\t\n\t},\n validate: function(frm){\n \n var regex = /[@#$%^*+\\\\[\\]{}`~:\\\\|\\?]+/;\n if(frm.doc.procedure_details){\n for (var i=0;iContent: Only letters, numbers and - ,'<>_()!=/; are allowed.\"));\n frappe.validated = false;\n }\n } \n }\n }\n \n frm.doc.procedure_filter = \"All\";\n if(frm.doc.procedure_filter == \"All\"){\n frm.get_field('procedure_details').grid.static_rows = false;\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').show();\n });\n }\n\n frm.refresh();\n },\n refresh: function (frm) {\n select_row(frm);\n if(frm.doc.procedure_filter == \"All\"){\n frm.get_field('procedure_details').grid.static_rows = false;\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').show();\n });\n }\n var previous_procedure_name = \"\";\n var previous_step_name = \"\";\n $(\"select[data-fieldname='procedure_filter']\").empty();\n $(\"select[data-fieldname='procedure_filter']\").append(new Option(\"All\", \"All\"));\n $(\"select[data-fieldname='step_filter']\").empty();\n $(\"select[data-fieldname='step_filter']\").append(new Option(\"All\", \"All\"));\n cur_frm.doc.procedure_filter = \"All\";\n cur_frm.doc.step_filter = \"All\";\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n if (row.doc.step_name){\n fn_addSteptolist(row.doc.step_name);\n }\n\n if (row.doc.procedure_name){\n fn_addProceduretolist(row.doc.procedure_name);\n }\n \n if (row.doc.procedure_name == previous_procedure_name){\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').find('div.col[data-fieldname=\"procedure_name\"]').find('a[data-doctype=\"Procedure Name\"]').css({'color': '#EDEDED'});\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').css({'background-color': '#FFFFFF'});\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').css({'border-bottom': '1px Solid #ebeef0'});\n }else{\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').find('div.col[data-fieldname=\"procedure_name\"]').find('a[data-doctype=\"Procedure Name\"]').css({'color': '#000000'});\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').css({'background-color': '#EDEDED'});\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').css({'border-bottom': '1px Solid #7b7c7c'});\n }\n previous_procedure_name = row.doc.procedure_name;\n \n \n if (row.doc.step_name == previous_step_name){\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').find('div.col[data-fieldname=\"step_name\"]').find('a[data-doctype=\"Procedure Step Name\"]').css({'color': '#DFDFDF'});\n }else{\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').find('div.col[data-fieldname=\"step_name\"]').find('a[data-doctype=\"Procedure Step Name\"]').css({'color': '#000000'});\n }\n previous_step_name = row.doc.step_name;\n let id = row.doc.idx;\n\n });\n\n if (frm.doc.workflow_state == \"Publish Ready\" && frappe.user_roles.indexOf(\"_Admin\") > 0){\n frm.add_custom_button(__('Revoke Publish'), function(){\n //get all system mapping with the procedure linked\n frappe.db.get_list('System Mapping_Sub System', {\n fields: ['parent', 'procedure', 'procedure_status'],\n filters: {\n procedure: frm.doc.name\n }\n }).then(records => {\n var html = \"

\";\n $.each(records, function(index, row){\n html = html + \"\" +\"\";\n });\n html = html + \"
\" + row.parent + \"\" + row.procedure + \"
\";\n frappe.warn('Are you sure you want to Revoke?',\n 'Since there are System Mappings attached to it!!! ' + html,\n () => {\n frm.set_value(\"workflow_state\",\"Draft\");\n frm.save();\n // action to perform if Continue is selected\n },\n 'Continue', false // Sets dialog as minimizable\n );\n });\n });\n }\n },\n \n procedure_filter: function (frm) {\n //if (!trigger){ trigger = true; return;}\n select_row(frm);\n if (frm.doc.procedure_filter ==\"All\"){\n frm.doc.step_filter = \"All\";\n cur_frm.refresh_field('step_filter');\n frm.get_field('procedure_details').grid.static_rows = false;\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').show();\n });\n } else {\n frm.get_field('procedure_details').grid.static_rows = false;\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n if (row.doc.procedure_name != frm.doc.procedure_filter){\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').hide();\n } else {\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').show();\n }\n });\n }\n //frm.refresh();\n \n //Filtered by as per step filter\n if(frm.doc.name && frm.is_new() == undefined){\n $(\"select[data-fieldname='step_filter']\").empty();\n\t\t$(\"select[data-fieldname='step_filter']\").append(new Option(\"All\", \"All\"));\n\t\tvar x = frappe.db.get_list('Procedure_Details', {\n\t\t\tfields: ['step_name'],\n\t\t\tfilters: {\n\t\t\t\tprocedure_name: frm.doc.procedure_filter,\n\t\t\t\tparent: frm.doc.name\n\t\t\t}\n\t\t\n\t\t}).then(steps => {\n\t\tvar child;\n\t\t\t$.each(steps, function(index, row){\n\t\t\t\tfn_steplist(row.step_name);\n\t\t\t})\n\t\t})\n }\n \n $(\"select[data-fieldname='step_filter']\").empty();\n\t\t$(\"select[data-fieldname='step_filter']\").append(new Option(\"All\", \"All\"));\n for(var i = 0;i {\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').show();\n });\n } else {\n frm.get_field('procedure_details').grid.static_rows = false;\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n if (row.doc.procedure_name == frm.doc.procedure_filter && row.doc.step_name == frm.doc.step_filter){\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').show();\n }else if(row.doc.procedure_name == frm.doc.procedure_filter && frm.doc.step_filter == \"All\"){\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').show();\n \n }else {\n $(\"div[data-fieldname=procedure_details]\").find('div.grid-row[data-idx=\"'+ row.doc.idx + '\"]').hide();\n }\n });\n }\n },\n \n before_workflow_action: (frm) => {\n if ((frm.doc.workflow_state == 'Review Pending' || frm.doc.workflow_state == 'Publish Ready') && (frm.selected_workflow_action == 'Revoke')){\n //frappe.throw(\"Any connected Publish Planning will get affected. Please check!\");\n frappe.call({\n \"method\": \"smart_service.transactions.doctype.procedure.procedure.get_publish_details\",\n \"args\": {\n \"procedure_name\": frm.doc.name,\n \"status\":'Published1',\n \t},\n \tfreeze: true,\n \tasync:false,\n \tcallback:function(r){\n \t var publish_list = r.message;\n \t if (publish_list.length){\n \t var html = \"This Procedure is linked with the following Publish Docs:
    \";\n \t publish_list.forEach((array_row) => {\n \t html = html + \"
  1. \" + array_row + \"
  2. \";\n \t });\n \t html = html + \"
\";\n frappe.msgprint({\n title: __('Notification'),\n indicator: 'green',\n message: __(html)\n });\n \t }\n \t}\n });\n }\n },\n mat:function(frm){\n if (!frm.is_new()){\n frappe.msgprint({\n title: __('Notification'),\n indicator: 'green',\n message: __('Updating MAT will impact its connected System Mapping and so with Kilometer Mapping. Please Check!')\n });\n }\n }\n});\n\nfrappe.ui.form.on('Procedure_Details', {\n procedure_name: function (frm,cdt,cdn) {\n var title = frm.doc.procedure_filter;\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n let value = row.doc.procedure_name;\n if (value)\n if ($(\"select[data-fieldname='procedure_filter'] option[value='\" + value + \"']\").length === 0){\n $(\"select[data-fieldname='procedure_filter']\").append(new Option(value, value));\n }\n \n });\n frm.doc.procedure_filter = title;\n // frm.refresh();\n },\n step_name: function (frm,cdt,cdn) {\n // frm.refresh();\n var filtered_step = frm.doc.step_filter;\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n let value = row.doc.step_name;\n if (value && frm.doc.procedure_filter == \"All\"){\n if ($(\"select[data-fieldname='step_filter'] option[value='\" + value + \"']\").length === 0){\n $(\"select[data-fieldname='step_filter']\").append(new Option(value, value));\n }\n }\n if(value && frm.doc.procedure_filter == row.doc.procedure_name){\n fn_stepfilter(row.doc.step_name)\n }\n });\n frm.doc.step_filter = filtered_step;\n\n },\n /*content_type: function (frm,cdt,cdn) {\n var df;\n let d = locals[cdt][cdn];\n var id = d.idx;\n id = id-1;\n let row = frm.fields_dict.procedure_details.grid.grid_rows[id];\n if (d.content_type == 'Link'){\n let d = new frappe.ui.Dialog({\n title: 'Select a Procedure',\n fields:[\n {\n label: 'Procedure',\n fieldname: 'procedure_map',\n fieldtype: 'Link',\n options:'Procedure'\n }\n ],\n primary_action_label: 'Select',\n primary_action(values) {\n // row.doc.content = values.procedure_map;\n var url = window.location.host;\n var content = values.procedure_map;\n row.doc.temp_cnt = values.procedure_map;\n row.doc.content = content.link(\"http://\" + url + \"/app/procedure/\" + content);\n // row.doc.content = '' + content + '';\n d.hide();\n frm.refresh();\n }\n });\n d.show();\n } else {\n d.content = d.content1;\n }\n },*/\n content_type: function (frm,cdt,cdn) {\n var df;\n let d = locals[cdt][cdn];\n var id = d.idx;\n id = id-1;\n let row = frm.fields_dict.procedure_details.grid.grid_rows[id];\n if(d.content_type != \"Link\"){\n d.system_id = '';\n cur_frm.refresh_fields();\n }\n if (d.content_type == 'Link'){\n let d = new frappe.ui.Dialog({\n title: 'Select a Procedure',\n fields:[\n {\n label: 'Variant Mapping',\n fieldname: 'variant_mapping',\n fieldtype: 'Link',\n options:'Variant Mapping',\n get_query: function() {\n return {\n \"query\": \"smart_service.transactions.doctype.procedure.procedure.get_variant\",\n \"filters\": {\n variant_mapping: frm.doc.variant_mapping\n \n }\n };\n },\n onchange: function() {\n cur_dialog.set_value(\"systems\", \"\");\n cur_dialog.set_value(\"sub_systems\", \"\");\n cur_dialog.set_value(\"procedure\", \"\");\n d.refresh()\n },\n },\n {\n label: 'Systems',\n fieldname: 'systems',\n fieldtype: 'Link',\n options:'Systems',\n get_query: function() {\n return {\n \"query\": \"smart_service.transactions.doctype.procedure.procedure.get_systems\",\n \"filters\": {\n variant_mapping: d.get_values()['variant_mapping'],\n language: frm.doc.language\n }\n };\n },\n onchange: function() {\n cur_dialog.set_value(\"sub_systems\", \"\");\n cur_dialog.set_value(\"procedure\",\"\");\n d.refresh()\n if (d.get_values()[\"systems\"]){\n frappe.call({\n method: \"smart_service.transactions.doctype.procedure.procedure.get_systemid\",\n args: {\n systems: d.get_values()[\"systems\"],\n },\n callback: function(r) {\n if(r.message) {\n cur_dialog.set_value(\"system_id\",r.message);\n d.refresh\n }\n }\n })\n }\n \n },\n },\n {\n label: 'Sub Systems',\n fieldname: 'sub_systems',\n fieldtype: 'Link',\n options:'Sub Systems',\n get_query: function() { \n \n return {\n \"query\": \"smart_service.transactions.doctype.procedure.procedure.get_subsystems\",\n \"filters\": {\n variant_mapping: d.get_values()['variant_mapping'],\n systems: d.get_values()['systems'],\n language: frm.doc.language\n }\n };\n },\n onchange: function() {\n cur_dialog.set_value(\"procedure\",\"\");\n d.refresh()\n if (d.get_values()['sub_systems']){\n frappe.call({\n method: \"smart_service.transactions.doctype.procedure.procedure.get_subsystemid\",\n args: {\n systems: d.get_values()['sub_systems'],\n },\n callback: function(r) {\n if(r.message) {\n cur_dialog.set_value(\"subsystem_id\",r.message);\n d.refresh\n }\n \n }\n })\n }\n if (d.get_values()['sub_systems']){\n frappe.call({\n method: \"smart_service.transactions.doctype.procedure.procedure.get_procedures\",\n args: {\n variant_mapping: d.get_values()['variant_mapping'],\n systems: d.get_values()['systems'],\n sub_systems: d.get_values()['sub_systems'],\n language: frm.doc.language\n },\n callback: function(r) {\n if(r.message) {\n cur_dialog.set_value(\"procedure\",r.message);\n d.refresh();\n }\n }\n \n \n })\n }\n },\n },\n {\n label: 'Procedure',\n fieldname: 'procedure',\n fieldtype: 'Link',\n options:'Procedure',\n read_only: 1,\n },\n {\n label: 'System Myid',\n fieldname: 'system_id',\n fieldtype: 'Data',\n hidden: 1,\n \n },\n {\n label: 'Sub System Myid',\n fieldname: 'subsystem_id',\n fieldtype: 'Data',\n hidden: 1,\n \n },\n ],\n primary_action_label: 'Select',\n primary_action(values) {\n var url = window.location.host;\n var content = values.procedure;\n //row.doc.temp_cnt = values.procedure;\n row.doc.system_id = values.variant_mapping + ',' + values.system_id + ',' + values.subsystem_id;\n // row.doc.content = content.link(\"http://\" + url + \"/app/procedure/\" + content);\n row.doc.content = '' + content + '';\n d.hide();\n frm.refresh();\n cur_frm.refresh_fields('procedure_details');\n }\n });\n d.show();\n } else {\n d.content = d.temp_cnt;\n \n }\n},\n procedure_details_move: function (frm,cdt,cdn) {\n frm.refresh();\n },\n procedure_details_remove: function(frm,cdt,cdn){\n frm.doc.procedure_filter = \"All\";\n frm.doc.step_filter = \"All\";\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n if (row.doc.procedure_name){\n fn_addProceduretolist(row.doc.procedure_name);\n }\n })\n frm.refresh_field('procedure_details');\n cur_frm.refresh_fields();\n frm.refresh();\n },\n procedure_details_add: function(frm,cdt,cdn) {\n select_row(frm);\n \tvar d = locals[cdt][cdn];\n \tvar id = d.idx;\n id = id-1;\n var row = frm.fields_dict.procedure_details.grid.grid_rows[id];\n var prevrow = frm.fields_dict.procedure_details.grid.grid_rows[id-1];\n if (frm.doc.procedure_filter == \"All\"){\n if (prevrow !== undefined) {\n row.doc.procedure_name = prevrow.doc.procedure_name;\n row.doc.step_name = prevrow.doc.step_name;\n }\n }else{\n row.doc.procedure_name = frm.doc.procedure_filter;\n // row.doc.step_name = prevrow.doc.step_name;\n }\n if (frm.doc.step_filter == \"All\" && frm.doc.procedure_filter == \"All\"){\n if (prevrow !== undefined) {\n row.doc.procedure_name = prevrow.doc.procedure_name;\n row.doc.step_name = prevrow.doc.step_name;\n }\n }\n else if(frm.doc.step_filter == \"All\" && frm.doc.procedure_filter != \"All\"){\n row.doc.procedure_name = frm.doc.procedure_filter;\n // row.doc.step_name = prevrow.doc.step_name;\n }else{\n row.doc.procedure_name = frm.doc.procedure_filter;\n row.doc.step_name = frm.doc.step_filter;\n }\n\n frm.fields_dict.procedure_details.grid.grid_rows.forEach((row) => {\n if (row.doc.step_name && row.doc.procedure_name == frm.doc.procedure_filter){\n fn_addSteptolist(row.doc.step_name);\n }\n })\n\n refresh_field(\"procedure_filter\");\n refresh_field(\"step_filter\");\n },\n});\n\nfunction fn_addProceduretolist(value){\n if (value === \"\") {return;}\n if ($(\"select[data-fieldname='procedure_filter'] option[value='\" + value + \"']\").length === 0){\n $(\"select[data-fieldname='procedure_filter']\").append(new Option(value, value));\n }\n}\nfunction fn_addSteptolist(value){\n if (value === \"\") {return;}\n if ($(\"select[data-fieldname='step_filter'] option[value='\" + value + \"']\").length === 0){\n $(\"select[data-fieldname='step_filter']\").append(new Option(value, value));\n }\n}\n\nfunction fn_steplist(value){\n\tif (value === \"\") {return;}\n\t\tif ($(\"select[data-fieldname='step_filter'] option[value='\" + value + \"']\").length === 0){\n\t\t\t$(\"select[data-fieldname='step_filter']\").append(new Option(value, value));\n\t\t}\n}\n\nfunction fn_stepfilter(value){\n\tif (value === \"\") {return;}\n\t \n\t\tif ($(\"select[data-fieldname='step_filter'] option[value='\" + value + \"']\").length === 0){\n\t\t\t$(\"select[data-fieldname='step_filter']\").append(new Option(value, value));\n\t\t}\n}\nfunction select_row(frm){\n if(frm.doc.procedure_filter != \"All\"){\n\t$('div[data-fieldname=procedure_details]').find('div[class=form-grid]').find('div[class=grid-heading-row]').find('div[class=\"row-index sortable-handle col col-xs-1\"]').find('input[class=\"grid-row-check pull-left\"]').css({'visibility': 'hidden'});\n\t}\n\telse{\n\t$('div[data-fieldname=procedure_details]').find('div[class=form-grid]').find('div[class=grid-heading-row]').find('div[class=\"row-index sortable-handle col col-xs-1\"]').find('input[class=\"grid-row-check pull-left\"]').css({'visibility': 'visible'});\n\n\t}\n\n}\ncur_frm.cscript.highlight_row = function(grid_row){\n\tvar idx = grid_row.doc.idx;\n\tcur_frm.fields_dict[\"procedure_details\"].$wrapper.find('.grid-body .rows').find(\".grid-row\").each(function(i, item) {\n\tlet d = locals[cur_frm.fields_dict[\"procedure_details\"].grid.doctype][$(item).attr('data-name')];\n\tif(d[\"idx\"] === idx){\n\t\tgrid_row.toggle_editable_row(true);\n\t}\n\t});\n}\n\n", "view": "Form" }, { diff --git a/smart_service/transactions/doctype/procedure/procedure.json b/smart_service/transactions/doctype/procedure/procedure.json index 3d7e03b..e387610 100644 --- a/smart_service/transactions/doctype/procedure/procedure.json +++ b/smart_service/transactions/doctype/procedure/procedure.json @@ -225,7 +225,7 @@ "fieldname": "procedure_details", "fieldtype": "Table", "label": "Procedure Details", - "options": "Procedure Details Table" + "options": "Procedure_Details" } ], "index_web_pages_for_search": 1,