diff --git a/smart_service/apis/v2/master.py b/smart_service/apis/v2/master.py
index f573eaa..407b7f1 100644
--- a/smart_service/apis/v2/master.py
+++ b/smart_service/apis/v2/master.py
@@ -55,15 +55,15 @@ def get_repair_service_mapping(vehicle, language):
try:
repair_service_details = []
if language == 'en':
- repair_service_details = frappe.db.sql(f""" select vehicle,vehicle_id,name,language,check_list_name,active_status,display_order,my_id from
+ repair_service_details = frappe.db.sql(f""" select vehicle,vehicle_id,name,language,check_list_name,active_status,display_order,my_id,keywords from
`tabRepair Service Mapping` where vehicle = '{vehicle}' and language = '{language}'; """, as_dict=1)
else:
- repair_service_details = frappe.db.sql(f""" select vehicle,vehicle_id,name,language,translated_check_list_name as check_list_name,active_status,
+ repair_service_details = frappe.db.sql(f""" select vehicle,vehicle_id,name,language,translated_check_list_name as check_list_name,active_status,keywords,
display_order,my_id from `tabRepair Service Mapping` where vehicle = '{vehicle}' and
language = '{language}'; """, as_dict=1)
for d in repair_service_details:
- d['complaint'] = frappe.db.sql(f""" select complaint,remedial_action_ok,remedial_action_not_ok,idx as display_order,active_status from
+ d['complaint'] = frappe.db.sql(f""" select complaint,remedial_action_ok,remedial_action_not_ok,idx as display_order from
`tabRepair Service Child` where parent = '{d['name']}' order by display_order ;""", as_dict=1)
return True, repair_service_details
@@ -77,6 +77,7 @@ def get_feature_finder(vehicle, variant, language):
feature_finder_details = []
if language == 'en':
feature_finder_details = frappe.db.sql(f"""select ff.name,ff.vehicle,ff.vehicle_id,ff.variant,ff.variant_id,ff.language,
+ ff.keywords,ff.sop_name,
ff.features_names as feature_name,ff.feature_category,ff.display_order,ff.active_status,
ffm.feature_pdf as pdf from `tabFeature Finder` ff left join `tabFeature Finder Master` ffm on
ff.features_names = ffm.feature_name
@@ -85,6 +86,7 @@ def get_feature_finder(vehicle, variant, language):
""", as_dict=1)
else:
feature_finder_details = frappe.db.sql(f"""select ff.name,ff.vehicle,ff.vehicle_id,ff.variant,ff.variant_id,ff.language,
+ ff.keywords,ff.sop_name,
ff.translated_feature_name as feature_name,ff.feature_category,
ff.display_order,ff.active_status,ffm.feature_pdf as pdf from `tabFeature Finder` ff
left join `tabFeature Finder Master` ffm on ff.features_names = ffm.feature_name
@@ -93,32 +95,32 @@ def get_feature_finder(vehicle, variant, language):
for f in feature_finder_details:
f['disclaimer'] = frappe.db.sql(f'''
- SELECT name,content,active_status,idx as display_order FROM `tabFeature Finder Disclaimer`
+ SELECT name,content,idx as display_order FROM `tabFeature Finder Disclaimer`
where parent = '{str(f['vehicle'])+ str('-')+ str(f['feature_name']) +str('-')+str(f['language'])}';
''', as_dict=1)
- sop_images = frappe.db.sql(f""" select image,idx as display_order,active_status from `tabFeature Finder Images` where
+ sop_images = frappe.db.sql(f""" select image,idx as display_order from `tabFeature Finder Images` where
parent = '{f['name']}' and feature_type ='SOP';""", as_dict=1)
- sop_content = frappe.db.sql(f"""select content,idx as display_order, active_status from `tabFeature Finder Content`
+ sop_content = frappe.db.sql(f"""select content,idx as display_order from `tabFeature Finder Content`
where parent = '{f['name']}' and feature_type ='SOP';""", as_dict=1)
- sop_specification = frappe.db.sql(f"""select specification,value,idx as display_order,active_status from `tabFeature Finder Specification`
+ sop_specification = frappe.db.sql(f"""select specification,value,idx as display_order from `tabFeature Finder Specification`
where parent = '{f['name']}' and feature_type ='SOP';""", as_dict=1)
f['sop'] = {'content': sop_content, 'images': sop_images,
- 'specificaton': sop_specification}
+ 'specificaton': sop_specification,'sop_name':f['sop_name']}
post_vin_data = frappe.db.sql(f'''select name,idx as display_order,post_vin_cutoff_name,post_vin_cutoff_id
from `tabPost Vin Cutoff ID` where parent = '{f['name']}';''', as_dict=1)
for p in post_vin_data:
- vin_content = frappe.db.sql(f"""select content,idx as display_order, active_status from `tabFeature Finder Content`
+ vin_content = frappe.db.sql(f"""select content,idx as display_order from `tabFeature Finder Content`
where parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}';""", as_dict=1)
- vin_images = frappe.db.sql(f""" select image,idx as display_order,active_status from `tabFeature Finder Images` where
+ vin_images = frappe.db.sql(f""" select image,idx as display_order from `tabFeature Finder Images` where
parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}';""", as_dict=1)
- vin_specification = frappe.db.sql(f"""select specification,value,idx as display_order,active_status from `tabFeature Finder Specification`
+ vin_specification = frappe.db.sql(f"""select specification,value,idx as display_order from `tabFeature Finder Specification`
where parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}';""", as_dict=1)
p['content'] = vin_content
p['images'] = vin_images
@@ -133,7 +135,7 @@ def get_feature_finder(vehicle, variant, language):
@frappe.whitelist(methods=["POST"], allow_guest=1)
def get_training_information(vehicle, language):
try:
- training_information = frappe.db.sql(f"""select name,vehicle,category,topic,language,active_status from`tabTraining Information`
+ training_information = frappe.db.sql(f"""select name,vehicle,category,topic,language,active_status,keywords from`tabTraining Information`
where vehicle = "{vehicle}" and language = "{language}"; """, as_dict=1)
for t in training_information:
@@ -224,7 +226,7 @@ def new_publish1():
@frappe.whitelist(methods=['POST'], allow_guest=1)
def get_special_tool_information(vehicle):
try:
- special_tool_details = frappe.db.sql(f''' select name,vehicle,category,sub_category,display_order, my_id from `tabSpecial Tool Information`
+ special_tool_details = frappe.db.sql(f''' select name,vehicle,category,sub_category,display_order, my_id,keywords from `tabSpecial Tool Information`
where vehicle="{vehicle}";''', as_dict=1)
for s in special_tool_details:
s['tool_usage_content'] = frappe.db.sql(f'''select idx as 'display_order',image,content,video,asset_type,active_status from `tabMST Information Assets`
diff --git a/smart_service/masters/doctype/app_labels/app_labels.js b/smart_service/masters/doctype/app_labels/app_labels.js
index 81564fe..9f56530 100644
--- a/smart_service/masters/doctype/app_labels/app_labels.js
+++ b/smart_service/masters/doctype/app_labels/app_labels.js
@@ -1,6 +1,6 @@
// Copyright (c) 2021, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
-
+var regex = /[!@#$%^&*()]+/;
frappe.ui.form.on('App Labels', {
is_group: function (frm) {
@@ -39,7 +39,7 @@ frappe.ui.form.on('App Labels', {
frappe.throw(__("Just a . is not prescribed!"));
frappe.validated = false;
}
- var regex = /[!@#$%^&*()+\=\[\]{};`~'"\\|.<>\/]+/;
+ // var regex = /[!@#$%^&*()+\=\[\]{};`~'"\\|.<>\/]+/;
if (frm.doc.english_label) {
if (regex.test(frm.doc.english_label) === true) {
frappe.throw(__("English Label : Only letters, numbers and - , are allowed."));
@@ -66,7 +66,7 @@ frappe.ui.form.on('App Labels', {
frappe.throw(__("Just a . is not prescribed!"));
frappe.validated = false;
}
- var regex = /[!@#$%^&*()+\=\[\]{};`~'"\\|.<>\/?]+/;
+ // var regex = /[!@#$%^&*()+\=\[\]{};`~'"\\|.<>\/?]+/;
if (frm.doc.page_name) {
if (regex.test(frm.doc.page_name) === true) {
frappe.throw(__("Page Name : Only letters, numbers and -, are allowed."));
@@ -93,7 +93,7 @@ frappe.ui.form.on('App Labels', {
frappe.throw(__("Just a . is not prescribed!"));
frappe.validated = false;
}
- var regex = /[!@#$%^&*()+\=\[\]{};`~'"\\|.<>\/]+/;
+ // var regex = /[!@#$%^&*()+\=\[\]{};`~'"\\|.<>\/]+/;
if (frm.doc.label) {
if (regex.test(frm.doc.label) === true) {
frappe.throw(__("Translated Label : Only letters, numbers and -, are allowed."));
diff --git a/smart_service/phase_2/doctype/feature_finder/feature_finder.js b/smart_service/phase_2/doctype/feature_finder/feature_finder.js
index b8b14b2..c329ce1 100644
--- a/smart_service/phase_2/doctype/feature_finder/feature_finder.js
+++ b/smart_service/phase_2/doctype/feature_finder/feature_finder.js
@@ -16,21 +16,21 @@ frappe.ui.form.on('Feature Finder', {
set_display_order(frm)
show_images(frm)
- var is_sop =1
- if(frm.doc.post_vin_cutoff_id_tab && frm.doc.post_vin_cutoff_id_tab.length>0){
- frm.doc.post_vin_cutoff_id_tab.map(v=>{
- if(v.post_vin_cutoff_name=="SOP"){
- is_sop=0
- }
- })
+ // var is_sop =1
+ // if(frm.doc.post_vin_cutoff_id_tab && frm.doc.post_vin_cutoff_id_tab.length>0){
+ // frm.doc.post_vin_cutoff_id_tab.map(v=>{
+ // if(v.post_vin_cutoff_name=="SOP"){
+ // is_sop=0
+ // }
+ // })
- }
- if(is_sop==1){
- var childTable = cur_frm.add_child("post_vin_cutoff_id_tab");
- childTable.post_vin_cutoff_name="SOP"
+ // }
+ // if(is_sop==1){
+ // var childTable = cur_frm.add_child("post_vin_cutoff_id_tab");
+ // childTable.post_vin_cutoff_name="SOP"
- cur_frm.refresh_fields("post_vin_cutoff_id_tab");
- }
+ // cur_frm.refresh_fields("post_vin_cutoff_id_tab");
+ // }
},
@@ -170,6 +170,7 @@ frappe.ui.form.on('Feature Finder', {
language: frm.doc.language,
}
}).then(records => {
+ console.log(records,"records")
if (records.length) {
frappe.db.set_value('Feature Finder', records[0].name, {
display_order: original_display_order
@@ -221,7 +222,9 @@ function set_display_order_child(doctype_name, values) {
}
function show_images(frm) {
var res = $(cur_frm.fields_dict.image_html.wrapper).empty();
- if (cur_frm.doc.feature_finder_images && cur_frm.doc.feature_finder_images.length > 0) {
+ var feature_finder_images_ = frm.doc.feature_finder_images.filter(o => o.feature_type == frm.doc.tab_ref)
+ if (cur_frm.doc.feature_finder_images && cur_frm.doc.feature_finder_images.length > 0 && feature_finder_images_.length>0) {
+
var img_html = ""
img_html += "
"
cur_frm.doc.feature_finder_images.map(val =>{
@@ -242,7 +245,12 @@ function custom_tab_html(frm) {
var res = $(cur_frm.fields_dict.test_html.wrapper).empty();
var ret = '
'
ret += '- '
- ret += 'SOP'
+ if(frm.doc.sop_name){
+ ret += ''+ frm.doc.sop_name+''
+ }else{
+ ret += 'SOP'
+ }
+
ret += '
'
if (frm.doc.post_vin_cutoff_id_tab && frm.doc.post_vin_cutoff_id_tab.length > 0) {
@@ -1124,7 +1132,6 @@ function set_display_order(frm) {
filters: {
"variant": cur_frm.doc.variant,
"language": frm.doc.language,
- "feature_name": frm.doc.feature_name,
// "feature_type":frm.doc.feature_type
}
}).then(count => {
diff --git a/smart_service/phase_2/doctype/feature_finder/feature_finder.json b/smart_service/phase_2/doctype/feature_finder/feature_finder.json
index 84831e2..c3bbf3c 100644
--- a/smart_service/phase_2/doctype/feature_finder/feature_finder.json
+++ b/smart_service/phase_2/doctype/feature_finder/feature_finder.json
@@ -1,4 +1,6 @@
{
+ "_comments": "[]",
+ "_liked_by": "[\"Administrator\"]",
"actions": [],
"allow_rename": 1,
"autoname": "format:{variant}-{features_names}-{language}",
@@ -19,7 +21,8 @@
"features_names",
"translated_feature_name",
"feature_category",
- "keyword",
+ "sop_name",
+ "keywords",
"section_break_u9bx1",
"image_html",
"create_feature_finder_images",
@@ -125,7 +128,6 @@
{
"fieldname": "specification",
"fieldtype": "Table",
- "hidden": 1,
"label": "Specification",
"options": "Feature Finder Specification"
},
@@ -196,14 +198,19 @@
"label": "Tab Ref"
},
{
- "fieldname": "keyword",
+ "fieldname": "keywords",
"fieldtype": "Small Text",
- "label": "Keyword"
+ "label": "Keywords"
+ },
+ {
+ "fieldname": "sop_name",
+ "fieldtype": "Data",
+ "label": "SOP Name"
}
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2023-09-01 17:00:59.504036",
+ "modified": "2023-09-15 10:05:47.926994",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder",
diff --git a/smart_service/phase_2/doctype/feature_finder/feature_finder.py b/smart_service/phase_2/doctype/feature_finder/feature_finder.py
index 3dd8751..0b4ef6c 100644
--- a/smart_service/phase_2/doctype/feature_finder/feature_finder.py
+++ b/smart_service/phase_2/doctype/feature_finder/feature_finder.py
@@ -24,6 +24,7 @@ class FeatureFinder(Document):
def validate(self):
try:
+ self.sop_name = self.sop_name.strip()
if self.is_new():
self.tab_ref = "SOP"
if self.variant and self.language and self.feature_name:
diff --git a/smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.json b/smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.json
index 5569357..bac2d03 100644
--- a/smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.json
+++ b/smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.json
@@ -1,4 +1,6 @@
{
+ "_comments": "[]",
+ "_liked_by": "[]",
"actions": [],
"allow_rename": 1,
"autoname": "format:{feature_name}",
@@ -47,7 +49,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2023-09-01 16:53:55.837109",
+ "modified": "2023-09-04 17:40:56.588347",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder Category Master",
diff --git a/smart_service/phase_2/doctype/feature_finder_master/feature_finder_master.json b/smart_service/phase_2/doctype/feature_finder_master/feature_finder_master.json
index ebe2069..e2b88cf 100644
--- a/smart_service/phase_2/doctype/feature_finder_master/feature_finder_master.json
+++ b/smart_service/phase_2/doctype/feature_finder_master/feature_finder_master.json
@@ -1,4 +1,6 @@
{
+ "_comments": "[]",
+ "_liked_by": "[]",
"actions": [],
"allow_rename": 1,
"autoname": "format:{vehicle}-{feature_name}-{language}",
@@ -75,7 +77,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2023-09-01 16:55:39.666635",
+ "modified": "2023-09-04 17:44:36.498919",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder Master",
diff --git a/smart_service/phase_2/doctype/feature_finder_specification_master/feature_finder_specification_master.json b/smart_service/phase_2/doctype/feature_finder_specification_master/feature_finder_specification_master.json
index ce775cd..c43b431 100644
--- a/smart_service/phase_2/doctype/feature_finder_specification_master/feature_finder_specification_master.json
+++ b/smart_service/phase_2/doctype/feature_finder_specification_master/feature_finder_specification_master.json
@@ -1,4 +1,6 @@
{
+ "_comments": "[]",
+ "_liked_by": "[]",
"actions": [],
"allow_rename": 1,
"autoname": "format:{specification}",
@@ -42,7 +44,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2023-08-29 16:08:19.671934",
+ "modified": "2023-09-04 17:40:40.990485",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder Specification Master",
diff --git a/smart_service/phase_2/doctype/module_publish_mapping/module_publish_mapping.json b/smart_service/phase_2/doctype/module_publish_mapping/module_publish_mapping.json
index fa0ee27..775bf41 100644
--- a/smart_service/phase_2/doctype/module_publish_mapping/module_publish_mapping.json
+++ b/smart_service/phase_2/doctype/module_publish_mapping/module_publish_mapping.json
@@ -1,4 +1,6 @@
{
+ "_comments": "[]",
+ "_liked_by": "[]",
"actions": [],
"allow_rename": 1,
"autoname": "format:{vehicle}-{variant}-{language}-{publish_type}",
@@ -141,7 +143,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2023-08-29 15:46:05.524052",
+ "modified": "2023-09-04 17:40:33.938964",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Module Publish Mapping",
diff --git a/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.json b/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.json
index b7ee444..44f3c2a 100644
--- a/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.json
+++ b/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.json
@@ -17,6 +17,7 @@
"display_order",
"column_break_azh0p",
"language",
+ "keywords",
"section_break_ecyyc",
"description",
"my_id",
@@ -122,11 +123,16 @@
"fieldtype": "Int",
"hidden": 1,
"label": "Vehicle Id"
+ },
+ {
+ "fieldname": "keywords",
+ "fieldtype": "Small Text",
+ "label": "Keywords"
}
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2023-09-01 17:04:14.589456",
+ "modified": "2023-09-04 10:18:54.190500",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Repair Service Mapping",
diff --git a/smart_service/phase_2/doctype/repair_service_master/repair_service_master.json b/smart_service/phase_2/doctype/repair_service_master/repair_service_master.json
index 66517d9..9e88802 100644
--- a/smart_service/phase_2/doctype/repair_service_master/repair_service_master.json
+++ b/smart_service/phase_2/doctype/repair_service_master/repair_service_master.json
@@ -1,4 +1,6 @@
{
+ "_comments": "[]",
+ "_liked_by": "[]",
"actions": [],
"autoname": "format:{repairservicename}",
"creation": "2023-07-20 17:52:46.159091",
@@ -50,7 +52,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2023-08-14 18:39:29.097473",
+ "modified": "2023-09-04 17:40:20.862739",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Repair Service Master",
diff --git a/smart_service/phase_2/doctype/repair_service_master_mapping/repair_service_master_mapping.json b/smart_service/phase_2/doctype/repair_service_master_mapping/repair_service_master_mapping.json
index 18c64f0..484cce0 100644
--- a/smart_service/phase_2/doctype/repair_service_master_mapping/repair_service_master_mapping.json
+++ b/smart_service/phase_2/doctype/repair_service_master_mapping/repair_service_master_mapping.json
@@ -1,4 +1,6 @@
{
+ "_comments": "[]",
+ "_liked_by": "[]",
"actions": [],
"allow_rename": 1,
"autoname": "format:{vehicle}-{check_list_name}-{language}",
@@ -107,7 +109,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2023-08-29 13:55:00.538663",
+ "modified": "2023-09-04 17:40:49.193155",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Repair Service Master Mapping",
diff --git a/smart_service/phase_2/doctype/special_tool_information/special_tool_information.js b/smart_service/phase_2/doctype/special_tool_information/special_tool_information.js
index 05f14b1..03905e0 100644
--- a/smart_service/phase_2/doctype/special_tool_information/special_tool_information.js
+++ b/smart_service/phase_2/doctype/special_tool_information/special_tool_information.js
@@ -63,7 +63,7 @@ function set_display_order(frm){
}
frappe.db.count('Special Tool Information',{
filters: {
- "vehicle": frm.doc.variant
+ "vehicle": frm.doc.vehicle,
}
})
.then(count => {
diff --git a/smart_service/phase_2/doctype/special_tool_information/special_tool_information.json b/smart_service/phase_2/doctype/special_tool_information/special_tool_information.json
index d346320..9a47570 100644
--- a/smart_service/phase_2/doctype/special_tool_information/special_tool_information.json
+++ b/smart_service/phase_2/doctype/special_tool_information/special_tool_information.json
@@ -1,4 +1,6 @@
{
+ "_comments": "[]",
+ "_liked_by": "[]",
"actions": [],
"allow_rename": 1,
"autoname": "format:{vehicle}-{category}-{sub_category}",
@@ -98,6 +100,11 @@
"label": "Active Status",
"options": "Active\nInactive"
},
+ {
+ "fieldname": "keywords",
+ "fieldtype": "Small Text",
+ "label": "Keywords"
+ },
{
"fieldname": "keywords",
"fieldtype": "Small Text",
@@ -106,7 +113,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2023-09-15 10:43:27.405396",
+ "modified": "2023-09-15 10:35:02.922534",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Special Tool Information",
diff --git a/smart_service/phase_2/doctype/training_information/training_information.js b/smart_service/phase_2/doctype/training_information/training_information.js
index 6bc4ada..28153dc 100644
--- a/smart_service/phase_2/doctype/training_information/training_information.js
+++ b/smart_service/phase_2/doctype/training_information/training_information.js
@@ -31,7 +31,7 @@ function set_display_order(frm){
filters: {
"variant": cur_frm.doc.variant,
"language": frm.doc.language,
- "feature_name": frm.doc.feature_name,
+ "vehicle": frm.doc.vehicle,
}
})
.then(count => {
diff --git a/smart_service/phase_2/doctype/training_information/training_information.json b/smart_service/phase_2/doctype/training_information/training_information.json
index bcd13df..ce3cd9a 100644
--- a/smart_service/phase_2/doctype/training_information/training_information.json
+++ b/smart_service/phase_2/doctype/training_information/training_information.json
@@ -1,4 +1,6 @@
{
+ "_comments": "[]",
+ "_liked_by": "[]",
"actions": [],
"allow_rename": 1,
"autoname": "format:{vehicle}-{category}-{topic}-{language}",
@@ -106,7 +108,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2023-09-01 17:11:02.486348",
+ "modified": "2023-09-04 17:41:29.001031",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Training Information",
diff --git a/smart_service/phase_2/doctype/training_information_master/training_information_master.json b/smart_service/phase_2/doctype/training_information_master/training_information_master.json
index 9be0bc3..1507b68 100644
--- a/smart_service/phase_2/doctype/training_information_master/training_information_master.json
+++ b/smart_service/phase_2/doctype/training_information_master/training_information_master.json
@@ -1,4 +1,6 @@
{
+ "_comments": "[]",
+ "_liked_by": "[]",
"actions": [],
"allow_rename": 1,
"autoname": "format:{category}-{topic}",
@@ -48,7 +50,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2023-09-01 17:10:00.219314",
+ "modified": "2023-09-04 17:40:09.769420",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Training Information Master",
diff --git a/smart_service/transactions/doctype/publish/publish.js b/smart_service/transactions/doctype/publish/publish.js
index fcaa15a..fb3bf2d 100644
--- a/smart_service/transactions/doctype/publish/publish.js
+++ b/smart_service/transactions/doctype/publish/publish.js
@@ -1,308 +1,611 @@
// Copyright (c) 2021, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
-
-cur_frm.fields_dict['variant_mapping'].get_query = function (doc, cdt, cdn) {
+cur_frm.fields_dict["variant_mapping"].get_query = function (doc, cdt, cdn) {
return {
query: "smart_service.transactions.doctype.publish.publish.variant",
- "filters": {
+ filters: {
vehicle: doc.vehicle,
- }
+ },
};
};
-var selected_module = ''
-cur_frm.fields_dict['vehicle'].get_query = function (doc, cdt, cdn) {
- return { query: "smart_service.masters.doctype.vehicle.vehicle.vehicle_filter", };
+var selected_module = "";
+cur_frm.fields_dict["vehicle"].get_query = function (doc, cdt, cdn) {
+ return {
+ query: "smart_service.masters.doctype.vehicle.vehicle.vehicle_filter",
+ };
};
let lang_set_first_time = true;
-frappe.ui.form.on('Publish', {
-
+frappe.ui.form.on("Publish", {
onload: function (frm) {
-
- if (frm.doc.hasOwnProperty('repiar_checksheet_publish_docs') && frm.doc.repiar_checksheet_publish_docs.length > 0 ) {
- frm.set_df_property('repiar_checksheet_publish_docs', 'hidden', 0)
- frm.refresh_field('repiar_checksheet_publish_docs')
- cur_frm.set_df_property('repiar_checksheet_publish_docs', 'read_only', 1)
-
+ if (
+ frm.doc.hasOwnProperty("repiar_checksheet_publish_docs") &&
+ frm.doc.repiar_checksheet_publish_docs.length > 0
+ ) {
+ frm.set_df_property("repiar_checksheet_publish_docs", "hidden", 0);
+ frm.refresh_field("repiar_checksheet_publish_docs");
+ cur_frm.set_df_property("repiar_checksheet_publish_docs", "read_only", 1);
}
- if (frm.doc.hasOwnProperty('feature_finder_publish_docs') && frm.doc.feature_finder_publish_docs.length > 0 ) {
- frm.set_df_property('feature_finder_publish_docs', 'hidden', 0)
- cur_frm.set_df_property('feature_finder_publish_docs', 'read_only', 1)
- frm.refresh_field('feature_finder_publish_docs')
-
+ if (
+ frm.doc.hasOwnProperty("feature_finder_publish_docs") &&
+ frm.doc.feature_finder_publish_docs.length > 0
+ ) {
+ frm.set_df_property("feature_finder_publish_docs", "hidden", 0);
+ cur_frm.set_df_property("feature_finder_publish_docs", "read_only", 1);
+ frm.refresh_field("feature_finder_publish_docs");
}
- if (frm.doc.docstatus == 1 && frm.doc.publish_module == 'Feature Finder') {
- cur_frm.set_df_property('kilometer_mapping_details', 'hidden', 1)
- cur_frm.set_df_property('feature_finder_publish_docs', 'read_only', 1)
- cur_frm.refresh_field('feature_finder_publish_docs')
- cur_frm.refresh_field('kilometer_mapping_details')
- cur_frm.remove_custom_button('Add To Publish');
+ if (frm.doc.docstatus == 1 && frm.doc.publish_module == "Feature Finder") {
+ cur_frm.set_df_property("kilometer_mapping_details", "hidden", 1);
+ cur_frm.set_df_property("feature_finder_publish_docs", "read_only", 1);
+ cur_frm.refresh_field("feature_finder_publish_docs");
+ cur_frm.refresh_field("kilometer_mapping_details");
+ cur_frm.remove_custom_button("Add To Publish");
if (frm.doc.feature_finder_publish.length > 0) {
- frm.set_df_property('feature_finder_publish', 'hidden', 1)
- frm.refresh_field('feature_finder_publish')
- cur_frm.set_df_property('feature_finder_publish', 'read_only', 1)
-
+ frm.set_df_property("feature_finder_publish", "hidden", 1);
+ frm.refresh_field("feature_finder_publish");
+ cur_frm.set_df_property("feature_finder_publish", "read_only", 1);
}
}
- if (frm.doc.docstatus == 1 && frm.doc.publish_module == 'Repair service') {
- cur_frm.set_df_property('repiar_checksheet_publish_docs', 'read_only', 1)
- cur_frm.refresh_field('repiar_checksheet_publish_docs')
- cur_frm.set_df_property('feature_finder_publish_docs', 'hidden', 1)
- cur_frm.remove_custom_button('Add To Publish');
+ if (frm.doc.docstatus == 1 && frm.doc.publish_module == "Repair service") {
+ cur_frm.set_df_property("repiar_checksheet_publish_docs", "read_only", 1);
+ cur_frm.refresh_field("repiar_checksheet_publish_docs");
+ cur_frm.set_df_property("feature_finder_publish_docs", "hidden", 1);
+ cur_frm.remove_custom_button("Add To Publish");
if (frm.doc.repiar_checksheet_publish_docs.length > 0) {
- frm.set_df_property('repiar_checksheet_publish_docs', 'hidden', 0)
- frm.refresh_field('repiar_checksheet_publish_docs')
- cur_frm.set_df_property('repiar_checksheet_publish_docs', 'read_only', 1)
-
+ frm.set_df_property("repiar_checksheet_publish_docs", "hidden", 0);
+ frm.refresh_field("repiar_checksheet_publish_docs");
+ cur_frm.set_df_property(
+ "repiar_checksheet_publish_docs",
+ "read_only",
+ 1
+ );
}
// cur_frm.set_df_property('repiar_checksheet_publish_docs','hidden',0)
// cur_frm.refresh_field('repiar_checksheet_publish_docs')
}
- if (frm.doc.docstatus != 1 && frm.doc.publish_module == 'Feature Finder' && frm.doc.feature_finder_publish_docs.length>0 && frm.doc.publish_type == 'Internal' || frm.doc.publish_type == 'Global') {
- cur_frm.set_df_property('kilometer_mapping_details', 'hidden', 1)
-
- cur_frm.refresh_field('feature_finder_publish_docs')
- cur_frm.refresh_field('kilometer_mapping_details')
- cur_frm.remove_custom_button('Add To Publish');
-
- cur_frm.set_df_property('feature_finder_publish_docs', 'hidden', 0)
- cur_frm.refresh_field('feature_finder_publish_docs')
+ if (
+ (frm.doc.docstatus != 1 &&
+ frm.doc.publish_module == "Feature Finder" &&
+ frm.doc.feature_finder_publish_docs.length > 0 &&
+ frm.doc.publish_type == "Internal") ||
+ frm.doc.publish_type == "Global"
+ ) {
+ cur_frm.set_df_property("kilometer_mapping_details", "hidden", 1);
+
+ cur_frm.refresh_field("feature_finder_publish_docs");
+ cur_frm.refresh_field("kilometer_mapping_details");
+ cur_frm.remove_custom_button("Add To Publish");
+
+ cur_frm.set_df_property("feature_finder_publish_docs", "hidden", 0);
+ cur_frm.refresh_field("feature_finder_publish_docs");
}
- if (frm.doc.docstatus != 1 && frm.doc.publish_module == 'Repair service' || frm.doc.publish_type == 'Internal' || frm.doc.publish_type == 'Global') {
- cur_frm.refresh_field('repiar_checksheet_publish_docs')
- cur_frm.refresh_field('kilometer_mapping_details')
- cur_frm.remove_custom_button('Add To Publish');
-
- cur_frm.set_df_property('repiar_checksheet_publish_docs', 'hidden', 0)
- cur_frm.refresh_field('repiar_checksheet_publish_docs')
+ if (
+ (frm.doc.docstatus != 1 && frm.doc.publish_module == "Repair service") ||
+ frm.doc.publish_type == "Internal" ||
+ frm.doc.publish_type == "Global"
+ ) {
+ cur_frm.refresh_field("repiar_checksheet_publish_docs");
+ cur_frm.refresh_field("kilometer_mapping_details");
+ cur_frm.remove_custom_button("Add To Publish");
+
+ cur_frm.set_df_property("repiar_checksheet_publish_docs", "hidden", 0);
+ cur_frm.refresh_field("repiar_checksheet_publish_docs");
}
-
// $('[data-route="Form/Publish/' + frm.doc.name + '"]').find('.primary-action').html("Internal Publish")
- if (frm.doc.docstatus == 0 && !frm.is_new() && frm.doc.publish_type != "Global" && frm.doc.publish_module != 'Automotive System') {
- $('[data-route="Form/Publish/' + frm.doc.name + '"]').find('.primary-action').html("Internal Publish")
+ if (
+ frm.doc.docstatus == 0 &&
+ !frm.is_new() &&
+ frm.doc.publish_type != "Global" &&
+ frm.doc.publish_module != "Automotive System"
+ ) {
+ $('[data-route="Form/Publish/' + frm.doc.name + '"]')
+ .find(".primary-action")
+ .html("Internal Publish");
}
- if (frm.doc.docstatus == 0 && frm.doc.publish_type == "Global" && frm.doc.publish_module != 'Automotive System') {
- $('[data-route="Form/Publish/' + frm.doc.name + '"]').find('.primary-action').html("Global Publish")
+ if (
+ frm.doc.docstatus == 0 &&
+ frm.doc.publish_type == "Global" &&
+ frm.doc.publish_module != "Automotive System"
+ ) {
+ $('[data-route="Form/Publish/' + frm.doc.name + '"]')
+ .find(".primary-action")
+ .html("Global Publish");
}
- $(document).on('mouseover', function (events) {
- $("a:contains(Copy to Clipboard)").css({ 'pointer-events': 'none' }),
- $("a:contains(Duplicate)").css({ 'pointer-events': 'none' });
+ $(document).on("mouseover", function (events) {
+ $("a:contains(Copy to Clipboard)").css({ "pointer-events": "none" }),
+ $("a:contains(Duplicate)").css({ "pointer-events": "none" });
}),
-
- lang_set_first_time = true;
- frm.get_field('publish_documents').grid.cannot_add_rows = true;
-
-
+ (lang_set_first_time = true);
+ frm.get_field("publish_documents").grid.cannot_add_rows = true;
},
planned_publish_date: function (frm) {
- let date = (frappe.datetime.nowdate())
+ let date = frappe.datetime.nowdate();
if (frm.doc.planned_publish_date < date) {
- frm.doc.planned_publish_date = '';
+ frm.doc.planned_publish_date = "";
cur_frm.refresh_fields();
- frappe.msgprint("Planned Publish Date: You can not select past date");
+ frappe.msgprint(
+ "Planned Publish Date: You can not select past date"
+ );
frappe.validated = false;
}
-
},
refresh: function (frm) {
-
- if (frm.doc.docstatus == 0 && !frm.is_new() && frm.doc.publish_type != "Global" && frm.doc.publish_module != "Automotive System") {
-
- $('[data-route="Form/Publish/' + frm.doc.name + '"]').find('.primary-action').html("Internal Publish")
+ if (
+ frm.doc.docstatus == 0 &&
+ !frm.is_new() &&
+ frm.doc.publish_type != "Global" &&
+ frm.doc.publish_module != "Automotive System"
+ ) {
+ $('[data-route="Form/Publish/' + frm.doc.name + '"]')
+ .find(".primary-action")
+ .html("Internal Publish");
}
- if (frm.doc.docstatus == 0 && frm.doc.publish_type == "Global" && frm.doc.publish_module != "Automotive System") {
-
- $('[data-route="Form/Publish/' + frm.doc.name + '"]').find('.primary-action').html("Global Publish")
+ if (
+ frm.doc.docstatus == 0 &&
+ frm.doc.publish_type == "Global" &&
+ frm.doc.publish_module != "Automotive System"
+ ) {
+ $('[data-route="Form/Publish/' + frm.doc.name + '"]')
+ .find(".primary-action")
+ .html("Global Publish");
}
- if (frm.doc.docstatus === 1 && frm.doc.publish_type == "Internal" && frm.doc.publish_status == 'Published' && frm.doc.publish_module != 'Automotive System' && !frm.doc.global_publish && frappe.user.has_role('_Publisher')) {
-
+ if (
+ frm.doc.docstatus === 1 &&
+ frm.doc.publish_type == "Internal" &&
+ frm.doc.publish_status == "Published" &&
+ frm.doc.publish_module != "Automotive System" &&
+ !frm.doc.global_publish &&
+ frappe.user.has_role("_Publisher")
+ ) {
frappe.call({
- method: "smart_service.transactions.doctype.publish.publish.max_publish_new_module",
+ method:
+ "smart_service.transactions.doctype.publish.publish.max_publish_new_module",
args: {
- "doc": frm.doc.name,
+ doc: frm.doc.name,
},
callback: function (r) {
if (r.message == frm.doc.version) {
+ frm
+ .add_custom_button(__("Global Publish"), function () {
+ frappe.confirm("Are you sure you want to Publish?", () => {
+ frappe.call({
+ method:
+ "smart_service.transactions.doctype.publish.publish.generate_global_publish",
+ args: {
+ name: frm.doc.name,
+ module_name: frm.doc.publish_module,
+ },
+ callback: function (r) {
+ debugger;
+ window.location.href =
+ r.message.url +
+ "/app/publish" +
+ "/" +
+ r.message.message;
+ },
+ });
+ });
+ })
+ .addClass("btn-warning")
+ .css({ "background-color": "#f5b0cd", color: "black" });
+ }
- if (r.message == frm.doc.version) {
+ },
+ });
+ }
- frm.add_custom_button(__('Global Publish'), function () {
- frappe.confirm('Are you sure you want to Publish?',
- () => {
+ if (frm.doc.publish_module == "Automotive System") {
+ cur_frm.set_df_property("system_mapping", "read_only", 1);
+ cur_frm.fields_dict["system_mapping"].grid.wrapper
+ .find(".grid-add-row")
+ .hide();
+ cur_frm.fields_dict["system_mapping"].grid.wrapper
+ .find(".grid-upload")
+ .hide();
+ cur_frm.fields_dict["system_mapping"].grid.wrapper
+ .find(".grid-remove-rows")
+ .hide();
+ cur_frm.fields_dict["system_mapping"].grid.wrapper
+ .find(".grid-insert-row")
+ .hide();
+ cur_frm.fields_dict["system_mapping"].grid.wrapper
+ .find(".grid-append-row")
+ .hide();
+ frm.fields_dict.system_mapping.grid.wrapper
+ .find(".grid-append-row")
+ .hide();
+
+ cur_frm.fields_dict["variant_mapping_assets"].grid.wrapper
+ .find(".grid-add-row")
+ .hide();
+ cur_frm.fields_dict["variant_mapping_assets"].grid.wrapper
+ .find(".grid-upload")
+ .hide();
+ cur_frm.fields_dict["variant_mapping_assets"].grid.wrapper
+ .find(".grid-remove-rows")
+ .hide();
+ cur_frm.fields_dict["variant_mapping_assets"].grid.wrapper
+ .find(".grid-insert-row")
+ .hide();
+ cur_frm.fields_dict["variant_mapping_assets"].grid.wrapper
+ .find(".grid-append-row")
+ .hide();
+ frm.fields_dict.variant_mapping_assets.grid.wrapper
+ .find(".grid-append-row")
+ .hide();
+
+ cur_frm.fields_dict["publish_documents"].grid.wrapper
+ .find(".grid-add-row")
+ .hide();
+ cur_frm.fields_dict["publish_documents"].grid.wrapper
+ .find(".grid-upload")
+ .hide();
+ cur_frm.fields_dict["publish_documents"].grid.wrapper
+ .find(".grid-remove-all-rows")
+ .hide();
+ cur_frm.fields_dict["publish_documents"].grid.wrapper
+ .find(".grid-remove-rows")
+ .hide();
+ cur_frm.fields_dict["publish_documents"].grid.wrapper
+ .find(".grid-delete-row")
+ .hide();
+ cur_frm.fields_dict["publish_documents"].grid.wrapper
+ .find(".grid-delete_all_rows")
+ .hide();
+ cur_frm.fields_dict["publish_documents"].grid.wrapper
+ .find(".grid-move-row")
+ .hide();
+ cur_frm.fields_dict["publish_documents"].grid.wrapper
+ .find(".grid-append-row")
+ .hide();
+ frm.fields_dict.publish_documents.grid.wrapper
+ .find(".grid-append-row")
+ .hide();
+
+ document.querySelectorAll(
+ "[data-fieldname='km_report']"
+ )[1].style.backgroundColor = "#e31a37";
+ document.querySelectorAll("[data-fieldname='km_report']")[1].style.color =
+ "#FFFFFF";
+ document.querySelectorAll(
+ "[data-fieldname='add_variant_mapping_to_publish']"
+ )[1].style.backgroundColor = "#e31a37";
+ document.querySelectorAll(
+ "[data-fieldname='add_variant_mapping_to_publish']"
+ )[1].style.color = "#FFFFFF";
+ if (
+ frm.doc.docstatus === 1 &&
+ frm.doc.publish_type == "Internal" &&
+ frm.doc.publish_status == "Published" &&
+ frm.doc.publish_module == "Automotive System" &&
+ !frm.doc.global_publish &&
+ frappe.user.has_role("_Publisher")
+ ) {
+ debugger;
+ frappe.call({
+ method:
+ "smart_service.transactions.doctype.publish.publish.max_publish",
+ args: {
+ doc: frm.doc.name,
+ },
+ callback: function (r) {
+ if (r.message) {
+ if (r.message == frm.doc.version) {
+ frm
+ .add_custom_button(__("Global Publish"), function () {
frappe.call({
- method: "smart_service.transactions.doctype.publish.publish.generate_global_publish",
+ method:
+ "smart_service.transactions.doctype.publish.publish.global_publish",
args: {
- "name": frm.doc.name,
- "module_name": frm.doc.publish_module
+ doc: frm.doc.name,
},
callback: function (r) {
-
- debugger
- window.location.href = r.message.url + "/app/publish" + "/" + r.message.message
-
- }
+ cur_frm.reload_doc();
+ },
});
-
})
-
- }).addClass("btn-warning").css({ 'background-color': '#f5b0cd', 'color': 'black' });
+ .addClass("btn-warning")
+ .css({ "background-color": "#f5b0cd", color: "black" });
+ }
}
- }
- }
- })
- }
-
- if (frm.doc.publish_module == 'Automotive System') {
- cur_frm.set_df_property('system_mapping', "read_only", 1);
- cur_frm.fields_dict['system_mapping'].grid.wrapper.find('.grid-add-row').hide();
- cur_frm.fields_dict['system_mapping'].grid.wrapper.find('.grid-upload').hide();
- cur_frm.fields_dict['system_mapping'].grid.wrapper.find('.grid-remove-rows').hide();
- cur_frm.fields_dict['system_mapping'].grid.wrapper.find('.grid-insert-row').hide();
- cur_frm.fields_dict['system_mapping'].grid.wrapper.find('.grid-append-row').hide();
- frm.fields_dict.system_mapping.grid.wrapper.find('.grid-append-row').hide();
-
- cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-add-row').hide();
- cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-upload').hide();
- cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-remove-rows').hide();
- cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-insert-row').hide();
- cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-append-row').hide();
- frm.fields_dict.variant_mapping_assets.grid.wrapper.find('.grid-append-row').hide();
-
- cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-add-row').hide();
- cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-upload').hide();
- cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-remove-all-rows').hide();
- cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-remove-rows').hide();
- cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-delete-row').hide();
- cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-delete_all_rows').hide();
- cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-move-row').hide();
- cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-append-row').hide();
- frm.fields_dict.publish_documents.grid.wrapper.find('.grid-append-row').hide();
-
- document.querySelectorAll("[data-fieldname='km_report']")[1].style.backgroundColor = "#e31a37";
- document.querySelectorAll("[data-fieldname='km_report']")[1].style.color = "#FFFFFF";
- document.querySelectorAll("[data-fieldname='add_variant_mapping_to_publish']")[1].style.backgroundColor = "#e31a37";
- document.querySelectorAll("[data-fieldname='add_variant_mapping_to_publish']")[1].style.color = "#FFFFFF";
- if (frm.doc.docstatus === 1 && frm.doc.publish_type == "Internal" && frm.doc.publish_status == 'Published' && frm.doc.publish_module == 'Automotive System' && !frm.doc.global_publish && frappe.user.has_role('_Publisher')) {
- debugger
- frappe.call({
- method: "smart_service.transactions.doctype.publish.publish.max_publish",
- args: {
- "doc": frm.doc.name,
},
- callback: function (r) {
- if (r.message) {
+ });
+ }
- if (r.message == frm.doc.version) {
- frm.add_custom_button(__('Global Publish'), function () {
+ if (
+ frm.doc.docstatus === 1 &&
+ frm.doc.publish_status == "To Publish" &&
+ frappe.user.has_role("_Publisher") &&
+ frm.doc.publish_module == "Automotive System"
+ ) {
+ debugger;
+ frm
+ .add_custom_button(__("Publish"), function () {
+ frappe.confirm(
+ "Are you sure you want to Publish?",
+ () => {
+ // action to perform if Yes is selected
+ if (
+ frm.doc.vehicle &&
+ frm.doc.language &&
+ frm.doc.publish_type
+ ) {
frappe.call({
- method: "smart_service.transactions.doctype.publish.publish.global_publish",
+ method:
+ "smart_service.transactions.doctype.publish.publish.cal_ver",
args: {
- "doc": frm.doc.name,
+ vehicle: frm.doc.vehicle,
+ lang: frm.doc.language,
+ publish_type: frm.doc.publish_type,
+ doc: frm.doc.name,
+ publish_module: frm.doc.publish_module,
+ },
+ callback: (r) => {
+ debugger;
+ frm.set_value("version", r.message);
+ cur_frm.refresh_field("version");
+ if (
+ frm.doc.docstatus === 1 &&
+ frm.doc.publish_status == "To Publish"
+ ) {
+ frappe.call({
+ // method: "smart_service.apis.publish_api.api_procedure",
+ method: "smart_service.apis.publish_api.new_publish",
+ args: {
+ args: frm.doc.name,
+ publish_type: frm.doc.publish_type,
+ vehicle: frm.doc.vehicle,
+ language: frm.doc.language,
+ version: frm.doc.version,
+ },
+ callback: function (r) {
+ // if (r.message[0]) {
+ frm.set_value("publish_status", "Published");
+ frm.page.clear_primary_action("Publish");
+ frm.set_value(
+ "actual_published_date",
+ frappe.datetime.nowdate()
+ );
+ frappe.call({
+ method:
+ "smart_service.transactions.doctype.publish.publish.update_procedure_value",
+ args: {
+ name: frm.doc.name,
+ file_path: r.message[1],
+ },
+ callback: (r) => {
+ // frm.save('Update');
+ },
+ });
+ frappe.msgprint({
+ title: __("Notification"),
+ message: __(
+ "Successfully Published: " + r.message[1]
+ ),
+ primary_action: {
+ action(values) {
+ frm.save("Update");
+ },
+ },
+ });
+ },
+ });
+ }
},
- callback: function (r) {
- cur_frm.reload_doc();
- }
});
- }).addClass("btn-warning").css({ 'background-color': '#f5b0cd', 'color': 'black' });
+ }
+ },
+ () => {
+ // action to perform if No is selected
}
- }
- }
- })
+ );
+ })
+ .addClass("btn-warning")
+ .css({ "background-color": "#f5b0cd", color: "black" });
+ } else if (frm.doc.publish_status == "Published") {
+ frm.set_read_only();
+ frm.set_df_property("add_variant_mapping_to_publish", "hidden", 1);
}
-
-
- if (frm.doc.docstatus === 1 && frm.doc.publish_status == 'To Publish' && frappe.user.has_role('_Publisher') && frm.doc.publish_module == 'Automotive System') {
- debugger
- frm.add_custom_button(__('Publish'), function () {
- frappe.confirm('Are you sure you want to Publish?',
- () => {
- // action to perform if Yes is selected
- if (frm.doc.vehicle && frm.doc.language && frm.doc.publish_type && frm.doc.publish_module == 'Automotive System') {
-
- frappe.call({
- method: 'smart_service.transactions.doctype.publish.publish.cal_ver',
- args: {
- vehicle: frm.doc.vehicle,
- lang: frm.doc.language,
- publish_type: frm.doc.publish_type,
- doc: frm.doc.name
- },
- callback: (r) => {
- debugger
- frm.set_value('version', r.message);
- cur_frm.refresh_field('version')
- if (frm.doc.docstatus === 1 && frm.doc.publish_status == 'To Publish') {
- frappe.call({
- // method: "smart_service.apis.publish_api.api_procedure",
- method: "smart_service.apis.publish_api.new_publish",
- args: {
- "args": frm.doc.name,
- "publish_type": frm.doc.publish_type,
- "vehicle": frm.doc.vehicle,
- "language": frm.doc.language,
- "version": frm.doc.version
- },
- callback: function (r) {
- // if (r.message[0]) {
- frm.set_value('publish_status', 'Published');
- frm.page.clear_primary_action("Publish");
- frm.set_value('actual_published_date', frappe.datetime.nowdate());
- frappe.call({
- method: "smart_service.transactions.doctype.publish.publish.update_procedure_value",
- args: {
- "name": frm.doc.name,
- "file_path": r.message[1],
- },
- callback: (r) => {
- // frm.save('Update');
- }
- })
- frappe.msgprint({
- title: __('Notification'),
- message: __('Successfully Published: ' + r.message[1]),
- primary_action: {
- action(values) {
- frm.save('Update');
- }
- }
- });
-
- }
- });
+ if (frm.doc.docstatus === 0 && frm.doc.publish_status == "To Publish") {
+ frm
+ .get_field("system_mapping")
+ .grid.add_custom_button(__("Add to Publish"), function () {
+ let added = 0;
+ let topublish = [];
+ if (frm.doc.publish_type == "Global") {
+ topublish = ["Publish Ready"];
+ } else {
+ topublish = [
+ "Review Pending",
+ "Publish Ready",
+ "Approval Pending",
+ ];
+ }
+ frm.doc.system_mapping.forEach((row) => {
+ if (topublish.indexOf(row.procedure_status) > -1) {
+ let dulicate = false;
+ if (frm.doc.publish_documents) {
+ frm.doc.publish_documents.forEach((publishrow) => {
+ if (
+ frm.doc.variant_mapping == publishrow.variant_mapping &&
+ row.systems == publishrow.system &&
+ row.sub_systems == publishrow.sub_system &&
+ row.procedure == publishrow.procedure_link
+ ) {
+ dulicate = true;
}
- },
- })
+ });
+ }
+ if (dulicate === false) {
+ let child = cur_frm.add_child("publish_documents");
+ child.variant_mapping = frm.doc.variant_mapping;
+ child.system = row.systems;
+ child.sub_system = row.sub_systems;
+ child.procedure_link = row.procedure;
+ child.procedure_status = row.procedure_status;
+ child.update_procedure_status = row.procedure_status;
+ child.item_category = "System Mapping";
+ child.variant = frm.doc.variant;
+ refresh_field("publish_documents");
+ added += 1;
+ }
}
- }, () => {
- // action to perform if No is selected
});
- }).addClass("btn-warning").css({ 'background-color': '#f5b0cd', 'color': 'black' });
+
+ if (added) {
+ frappe.msgprint(__(added + " Doc(s) Added"));
+ } else {
+ frappe.msgprint(__("No Doc Added"));
+ }
+ });
+ frm.fields_dict.system_mapping.grid.grid_buttons
+ .find(".btn-custom")
+ .removeClass("btn-default")
+ .addClass("btn-primary");
}
- else if (frm.doc.publish_status == 'Published') {
- frm.set_read_only();
- frm.set_df_property('add_variant_mapping_to_publish', 'hidden', 1);
+ if (frm.doc.docstatus === 0 && frm.doc.publish_status == "To Publish") {
+ frm
+ .get_field("variant_mapping_assets")
+ .grid.add_custom_button(__("Add to Publish"), function () {
+ let added = 0;
+ frm.doc.variant_mapping_assets.forEach((row) => {
+ if (
+ row.active_status == "Active" ||
+ row.active_status == "Inactive"
+ ) {
+ let dulicate = false;
+ if (frm.doc.publish_documents) {
+ frm.doc.publish_documents.forEach((publishrow) => {
+ if (
+ frm.doc.variant_mapping == publishrow.variant_mapping &&
+ row.category == publishrow.asset_category &&
+ row.attach_file == publishrow.attach_file
+ ) {
+ dulicate = true;
+ }
+ });
+ }
+ if (dulicate === false) {
+ let child = cur_frm.add_child("publish_documents");
+ child.variant_mapping = frm.doc.variant_mapping;
+ child.asset_category = row.category;
+ child.item_category = "Variant Mapping Assets";
+ child.variant = frm.doc.variant;
+ child.attach_file = row.attach_file;
+ refresh_field("publish_documents");
+ added += 1;
+ }
+ }
+ });
+ if (added) {
+ frappe.msgprint(__(added + " Doc(s) Added"));
+ } else {
+ frappe.msgprint(__("No Doc Added"));
+ }
+ });
+
+ frm.fields_dict.variant_mapping_assets.grid.grid_buttons
+ .find(".btn-custom")
+ .removeClass("btn-default")
+ .addClass("btn-primary");
}
+ if (frm.doc.docstatus == 1) {
+ $(".grid-buttons").hide();
+ }
+ }
+ if (
+ frm.doc.docstatus == 1 &&
+ frm.doc.publish_status == "To Publish" &&
+ !frm.is_new() &&
+ frm.doc.publish_module != "Automotive System"
+ ) {
+ frappe.call({
+ method:
+ "smart_service.transactions.doctype.publish.publish.cal_ver_new_module",
+ args: {
+ vehicle: frm.doc.vehicle,
+ lang: frm.doc.language,
+ publish_type: frm.doc.publish_type,
+ doc: frm.doc.name,
+ },
+ callback: function (r) {
+ if (r.message) {
+ frm.set_value("version", r.message);
+ cur_frm.refresh_field("version");
+ frm.set_value("actual_published_date", frappe.datetime.nowdate());
+ window.location.reload();
+ }
+ },
+ });
+ }
+ },
+ validate: function (frm) {
+ if (frm.doc.publish_module == "Automotive System") {
+ let regex = /[!@#$%^*_+\=\[\]{};'`~\\|.<>\?]+/;
+ if (regex.test(frm.doc.release_description) === true) {
+ frm.doc.release_description = "";
+ frm.refresh_fields();
+ frappe.msgprint(
+ __(
+ "Publish Description: Only letters, numbers and / - () & , ' : are allowed."
+ )
+ );
+ }
- if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish') {
- frm.get_field('system_mapping').grid.add_custom_button(__('Add to Publish'), function () {
+ if (
+ frm.doc.vehicle &&
+ frm.doc.release_description &&
+ frm.fields_dict.publish_documents.grid.grid_rows.length === 0
+ ) {
+ frappe.msgprint(__("No item selected to Publish"));
+ frappe.validated = false;
+ }
+ if (frm.doc.planned_publish_date < frappe.datetime.get_today()) {
+ frappe.msgprint(
+ __("Planned Publish Date: You can not select past date")
+ );
+ frappe.validated = false;
+ }
+ }
+ //check for atleast one data to publish
+ if (
+ frm.doc.publish_module != "Automotive System" &&
+ !frm.doc.hasOwnProperty("repair_checksheet_publish") &&
+ !frm.doc.hasOwnProperty("feature_finder_publish")
+ ) {
+ frappe.throw("No Data Found To Publish");
+ }
+ },
+ variant_mapping: function (frm) {
+ if (frm.doc.docstatus === 0 && frm.doc.publish_status == "To Publish") {
+ frm
+ .get_field("system_mapping")
+ .grid.add_custom_button(__("Add to Publish"), function () {
let added = 0;
let topublish = [];
- if (frm.doc.publish_type == 'Global') { topublish = ['Publish Ready']; } else { topublish = ['Review Pending', 'Publish Ready', 'Approval Pending']; }
- frm.doc.system_mapping.forEach(row => {
+ if (frm.doc.publish_type == "Global") {
+ topublish = ["Publish Ready"];
+ } else {
+ topublish = ["Review Pending", "Publish Ready", "Approval Pending"];
+ }
+ frm.doc.system_mapping.forEach((row) => {
if (topublish.indexOf(row.procedure_status) > -1) {
let dulicate = false;
if (frm.doc.publish_documents) {
- frm.doc.publish_documents.forEach(publishrow => {
- if (frm.doc.variant_mapping == publishrow.variant_mapping &&
+ frm.doc.publish_documents.forEach((publishrow) => {
+ if (
+ frm.doc.variant_mapping == publishrow.variant_mapping &&
row.systems == publishrow.system &&
- row.sub_systems == publishrow.sub_system && row.procedure == publishrow.procedure_link) {
+ row.sub_systems == publishrow.sub_system &&
+ row.procedure == publishrow.procedure_link
+ ) {
dulicate = true;
}
});
@@ -323,22 +626,35 @@ frappe.ui.form.on('Publish', {
}
});
- if (added) { frappe.msgprint(__(added + " Doc(s) Added")); }
- else { frappe.msgprint(__("No Doc Added")); }
+ if (added) {
+ frappe.msgprint(__(added + " Doc(s) Added"));
+ } else {
+ frappe.msgprint(__("No Doc Added"));
+ }
});
- frm.fields_dict.system_mapping.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
-
- }
- if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish') {
- frm.get_field('variant_mapping_assets').grid.add_custom_button(__('Add to Publish'), function () {
+ frm.fields_dict.system_mapping.grid.grid_buttons
+ .find(".btn-custom")
+ .removeClass("btn-default")
+ .addClass("btn-primary");
+ }
+ if (frm.doc.docstatus === 0 && frm.doc.publish_status == "To Publish") {
+ frm
+ .get_field("variant_mapping_assets")
+ .grid.add_custom_button(__("Add to Publish"), function () {
let added = 0;
- frm.doc.variant_mapping_assets.forEach(row => {
- if (row.active_status == "Active" || row.active_status == "Inactive") {
+ frm.doc.variant_mapping_assets.forEach((row) => {
+ if (
+ row.active_status == "Active" ||
+ row.active_status == "Inactive"
+ ) {
let dulicate = false;
if (frm.doc.publish_documents) {
- frm.doc.publish_documents.forEach(publishrow => {
- if (frm.doc.variant_mapping == publishrow.variant_mapping &&
- row.category == publishrow.asset_category && row.attach_file == publishrow.attach_file) {
+ frm.doc.publish_documents.forEach((publishrow) => {
+ if (
+ frm.doc.variant_mapping == publishrow.variant_mapping &&
+ row.category == publishrow.asset_category &&
+ row.attach_file == publishrow.attach_file
+ ) {
dulicate = true;
}
});
@@ -355,158 +671,30 @@ frappe.ui.form.on('Publish', {
}
}
});
- if (added) { frappe.msgprint(__(added + " Doc(s) Added")); }
- else { frappe.msgprint(__("No Doc Added")); }
- });
-
- frm.fields_dict.variant_mapping_assets.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
- }
-
- if (frm.doc.docstatus == 1) {
- $(".grid-buttons").hide();
-
-
- }
-
- }
-
-
- if (frm.doc.docstatus == 1 && frm.doc.publish_status == 'To Publish' && !frm.is_new() && frm.doc.publish_module != 'Automotive System') {
-
- frappe.call({
- method: "smart_service.transactions.doctype.publish.publish.cal_ver_new_module",
- args: {
- vehicle: frm.doc.vehicle,
- lang: frm.doc.language,
- publish_type: frm.doc.publish_type,
- doc: frm.doc.name
- },
- callback: function (r) {
-
- if (r.message) {
-
- frm.set_value('version', r.message);
- cur_frm.refresh_field('version')
- frm.set_value('actual_published_date', frappe.datetime.nowdate());
- window.location.reload();
-
- }
- }
- })
-
- }
-
-
-
- },
- validate: function (frm) {
- if (frm.doc.publish_module == 'Automotive System') {
- let regex = /[!@#$%^*_+\=\[\]{};'`~\\|.<>\?]+/;
- if (regex.test(frm.doc.release_description) === true) {
- frm.doc.release_description = '';
- frm.refresh_fields();
- frappe.msgprint(__("Publish Description: Only letters, numbers and / - () & , ' : are allowed."));
- }
-
- if (frm.doc.vehicle && frm.doc.release_description && frm.fields_dict.publish_documents.grid.grid_rows.length === 0) {
- frappe.msgprint(__("No item selected to Publish"));
- frappe.validated = false;
- }
- if (frm.doc.planned_publish_date < frappe.datetime.get_today()) {
- frappe.msgprint(__("Planned Publish Date: You can not select past date"));
- frappe.validated = false;
- }
-
- }
- //check for atleast one data to publish
- if (frm.doc.publish_module != 'Automotive System' && !frm.doc.hasOwnProperty('repair_checksheet_publish') && !frm.doc.hasOwnProperty('feature_finder_publish')) {
- frappe.throw('No Data Found To Publish')
-
-
- }
-
- },
- variant_mapping: function (frm) {
-
- if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish') {
- frm.get_field('system_mapping').grid.add_custom_button(__('Add to Publish'), function () {
- let added = 0;
- let topublish = [];
- if (frm.doc.publish_type == 'Global') { topublish = ['Publish Ready']; } else { topublish = ['Review Pending', 'Publish Ready', 'Approval Pending']; }
- frm.doc.system_mapping.forEach(row => {
- if (topublish.indexOf(row.procedure_status) > -1) {
- let dulicate = false;
- if (frm.doc.publish_documents) {
- frm.doc.publish_documents.forEach(publishrow => {
- if (frm.doc.variant_mapping == publishrow.variant_mapping &&
- row.systems == publishrow.system &&
- row.sub_systems == publishrow.sub_system && row.procedure == publishrow.procedure_link) {
- dulicate = true;
- }
- });
- }
- if (dulicate === false) {
- let child = cur_frm.add_child("publish_documents");
- child.variant_mapping = frm.doc.variant_mapping;
- child.system = row.systems;
- child.sub_system = row.sub_systems;
- child.procedure_link = row.procedure;
- child.procedure_status = row.procedure_status;
- child.update_procedure_status = row.procedure_status;
- child.item_category = "System Mapping";
- child.variant = frm.doc.variant;
- refresh_field("publish_documents");
- added += 1;
- }
+ if (added) {
+ frappe.msgprint(__(added + " Doc(s) Added"));
+ } else {
+ frappe.msgprint(__("No Doc Added"));
}
});
- if (added) { frappe.msgprint(__(added + " Doc(s) Added")); }
- else { frappe.msgprint(__("No Doc Added")); }
- });
- frm.fields_dict.system_mapping.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
-
+ frm.fields_dict.variant_mapping_assets.grid.grid_buttons
+ .find(".btn-custom")
+ .removeClass("btn-default")
+ .addClass("btn-primary");
}
- if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish') {
- frm.get_field('variant_mapping_assets').grid.add_custom_button(__('Add to Publish'), function () {
- let added = 0;
- frm.doc.variant_mapping_assets.forEach(row => {
- if (row.active_status == "Active" || row.active_status == "Inactive") {
- let dulicate = false;
- if (frm.doc.publish_documents) {
- frm.doc.publish_documents.forEach(publishrow => {
- if (frm.doc.variant_mapping == publishrow.variant_mapping &&
- row.category == publishrow.asset_category && row.attach_file == publishrow.attach_file) {
- dulicate = true;
- }
- });
- }
- if (dulicate === false) {
- let child = cur_frm.add_child("publish_documents");
- child.variant_mapping = frm.doc.variant_mapping;
- child.asset_category = row.category;
- child.item_category = "Variant Mapping Assets";
- child.variant = frm.doc.variant;
- child.attach_file = row.attach_file;
- refresh_field("publish_documents");
- added += 1;
- }
- }
- });
- if (added) { frappe.msgprint(__(added + " Doc(s) Added")); }
- else { frappe.msgprint(__("No Doc Added")); }
- });
-
- frm.fields_dict.variant_mapping_assets.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
- }
-
- frappe.db.get_value('Variant Mapping', { name: frm.doc.variant_mapping }, ['fuel', 'transmission', 'drive'], (r) => {
- frm.doc.variant = r.fuel + ',' + r.transmission + ',' + r.drive;
- cur_frm.refresh_field('variant');
- })
- if (frm.doc.publish_module == 'Feature Finder') {
- add_feature_finder(frm)
+ frappe.db.get_value(
+ "Variant Mapping",
+ { name: frm.doc.variant_mapping },
+ ["fuel", "transmission", "drive"],
+ (r) => {
+ frm.doc.variant = r.fuel + "," + r.transmission + "," + r.drive;
+ cur_frm.refresh_field("variant");
+ }
+ );
+ if (frm.doc.publish_module == "Feature Finder") {
+ add_feature_finder(frm);
}
// if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish' && frm.doc.publish_module=='Feature Finder') {
@@ -553,55 +741,80 @@ frappe.ui.form.on('Publish', {
// frm.fields_dict.repair_checksheet_publish.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
// }
- if (frm.doc.publish_module == 'Automotive System') {
+ if (frm.doc.publish_module == "Automotive System") {
let km_name = frm.doc.variant_mapping + "-" + frm.doc.language + "-KM";
- frappe.db.get_value('Kilometer Mapping', { name: km_name }, 'workflow_state', (r) => {
- if (r.workflow_state == "Draft") {
- frm.doc.kilometer_mapping = '';
- frm.doc.variant_mapping = '';
- frm.doc.system_mapping = '';
- frm.doc.variant_mapping_status = '';
- frm.refresh_field('kilometer_mapping');
- frm.refresh_field('variant_mapping');
- frm.refresh_field('system_mapping');
- frappe.msgprint("System Mapping details cannot be loaded due to kilometer mapping in draft state");
- frappe.validated = false;
- }
-
- else {
- if (frm.doc.variant_mapping === undefined) { return; }
- // frm.set_value('system_mapping', null);
- // frm.set_value('variant_mapping_assets', null);
- frappe.db.exists('Kilometer Mapping', frm.doc.variant_mapping + "-" + frm.doc.language + "-KM")
- .then(exists => {
- if (exists) {
- frm.set_value("kilometer_mapping", frm.doc.variant_mapping + "-" + frm.doc.language + "-KM");
- frm.refresh_field('kilometer_mapping')
- } else {
- frm.set_value("km_active_status", "Not Configured!");
- }
- });
+ frappe.db.get_value(
+ "Kilometer Mapping",
+ { name: km_name },
+ "workflow_state",
+ (r) => {
+ if (r.workflow_state == "Draft") {
+ frm.doc.kilometer_mapping = "";
+ frm.doc.variant_mapping = "";
+ frm.doc.system_mapping = "";
+ frm.doc.variant_mapping_status = "";
+ frm.refresh_field("kilometer_mapping");
+ frm.refresh_field("variant_mapping");
+ frm.refresh_field("system_mapping");
+ frappe.msgprint(
+ "System Mapping details cannot be loaded due to kilometer mapping in draft state"
+ );
+ frappe.validated = false;
+ } else {
+ if (frm.doc.variant_mapping === undefined) {
+ return;
+ }
+ // frm.set_value('system_mapping', null);
+ // frm.set_value('variant_mapping_assets', null);
+ frappe.db
+ .exists(
+ "Kilometer Mapping",
+ frm.doc.variant_mapping + "-" + frm.doc.language + "-KM"
+ )
+ .then((exists) => {
+ if (exists) {
+ frm.set_value(
+ "kilometer_mapping",
+ frm.doc.variant_mapping + "-" + frm.doc.language + "-KM"
+ );
+ frm.refresh_field("kilometer_mapping");
+ } else {
+ frm.set_value("km_active_status", "Not Configured!");
+ }
+ });
+ }
}
- })
+ );
}
-
},
km_active_status: function (frm) {
- if (frm.doc.variant_mapping && frm.doc.publish_module == 'Automotive System') {
- frappe.show_alert({
- message: __('Please wait until variant mapping details are loaded.'),
- indicator: 'yellow'
- }, 5);
+ if (
+ frm.doc.variant_mapping &&
+ frm.doc.publish_module == "Automotive System"
+ ) {
+ frappe.show_alert(
+ {
+ message: __("Please wait until variant mapping details are loaded."),
+ indicator: "yellow",
+ },
+ 5
+ );
+ }
+ if (frm.doc.km_active_status === "" || frm.doc.km_active_status === null) {
+ return;
}
- if (frm.doc.km_active_status === "" || frm.doc.km_active_status === null) { return; }
let filter = frm.doc.variant_mapping + "-" + frm.doc.language + "-SM";
- if (frm.doc.variant_mapping_status == "Active" && frm.doc.km_active_status == "Active" && frm.doc.publish_module == 'Automotive System') {
+ if (
+ frm.doc.variant_mapping_status == "Active" &&
+ frm.doc.km_active_status == "Active" &&
+ frm.doc.publish_module == "Automotive System"
+ ) {
frappe.call({
- "method": "smart_service.transactions.doctype.publish.publish.get_system",
- "args": {
- "doc": frm.doc.variant_mapping,
- "name": filter,
- "lang": frm.doc.language
+ method: "smart_service.transactions.doctype.publish.publish.get_system",
+ args: {
+ doc: frm.doc.variant_mapping,
+ name: filter,
+ lang: frm.doc.language,
},
callback: function (r) {
$.each(r.message, function (index, row) {
@@ -617,18 +830,18 @@ frappe.ui.form.on('Publish', {
child.mat = row.mat;
child.procedure = row.procedure;
child.procedure_status = row.procedure_status;
- cur_frm.refresh_field('system_mapping');
+ cur_frm.refresh_field("system_mapping");
cur_frm.refresh_fields();
- })
- }
-
- })
+ });
+ },
+ });
frappe.call({
- "method": "smart_service.transactions.doctype.publish.publish.get_vm_asset",
- "args": {
- "doc": frm.doc.variant_mapping,
- "lang": frm.doc.language
+ method:
+ "smart_service.transactions.doctype.publish.publish.get_vm_asset",
+ args: {
+ doc: frm.doc.variant_mapping,
+ lang: frm.doc.language,
},
callback: function (r) {
$.each(r.message, function (index, row) {
@@ -638,19 +851,19 @@ frappe.ui.form.on('Publish', {
child.language = row.language;
child.attach_file = row.attach_file;
child.active_status = row.active_status;
- cur_frm.refresh_field('variant_mapping_assets');
+ cur_frm.refresh_field("variant_mapping_assets");
cur_frm.refresh_fields();
- })
- }
-
- })
+ });
+ },
+ });
frappe.call({
- "method": "smart_service.transactions.doctype.publish.publish.get_sm_asset",
- "args": {
- "doc": frm.doc.variant_mapping,
- "name": filter,
- "lang": frm.doc.language
+ method:
+ "smart_service.transactions.doctype.publish.publish.get_sm_asset",
+ args: {
+ doc: frm.doc.variant_mapping,
+ name: filter,
+ lang: frm.doc.language,
},
callback: function (r) {
$.each(r.message, function (index, row) {
@@ -660,34 +873,45 @@ frappe.ui.form.on('Publish', {
child_row.language = row.language;
child_row.attach_file = row.system_asset;
child_row.active_status = row.active_status;
- cur_frm.refresh_field('variant_mapping_assets');
+ cur_frm.refresh_field("variant_mapping_assets");
cur_frm.refresh_fields();
- })
- }
-
- })
-
+ });
+ },
+ });
} else {
- if (frm.doc.variant_mapping_status && frm.doc.publish_module == 'Automotive System') {
+ if (
+ frm.doc.variant_mapping_status &&
+ frm.doc.publish_module == "Automotive System"
+ ) {
frappe.msgprint({
- title: __('Notification'),
- indicator: 'red',
- message: __('System Mapping & Assets not loaded as the selected Variant/Kilometer Mapping is Inactive or not configured')
+ title: __("Notification"),
+ indicator: "red",
+ message: __(
+ "System Mapping & Assets not loaded as the selected Variant/Kilometer Mapping is Inactive or not configured"
+ ),
});
}
}
},
add_variant_mapping_to_publish: function (frm) {
let dulicate = false;
- if (frm.doc.publish_documents && frm.doc.publish_module == 'Automotive System') {
- frm.doc.publish_documents.forEach(publishrow => {
- if (frm.doc.variant_mapping == publishrow.variant_mapping && publishrow.systems === undefined && publishrow.sub_systems === undefined && publishrow.procedure === undefined) {
+ if (
+ frm.doc.publish_documents &&
+ frm.doc.publish_module == "Automotive System"
+ ) {
+ frm.doc.publish_documents.forEach((publishrow) => {
+ if (
+ frm.doc.variant_mapping == publishrow.variant_mapping &&
+ publishrow.systems === undefined &&
+ publishrow.sub_systems === undefined &&
+ publishrow.procedure === undefined
+ ) {
dulicate = true;
}
});
frappe.msgprint("Variant Mapping already added");
}
- if (dulicate === false && frm.doc.publish_module == 'Automotive System') {
+ if (dulicate === false && frm.doc.publish_module == "Automotive System") {
let child = cur_frm.add_child("publish_documents");
child.variant_mapping = frm.doc.variant_mapping;
child.item_category = "Variant Mapping";
@@ -715,377 +939,482 @@ frappe.ui.form.on('Publish', {
// frappe.msgprint(__(frm.doc.variant_mapping + " Added"));
// }
// else{
- // frappe.msgprint(__(row.parent1 + 'Alraeady Added'))
+ // frappe.msgprint(__(row.parent1 + 'Alraeady Added'))
// }
},
km_report: function (frm, cdt, cdn) {
- if (frm.doc.publish_module == 'Automotive System') {
- frappe.set_route("query-report", 'Kilometer Mapping', { 'kilometer_mapping': frm.doc.kilometer_mapping });
+ if (frm.doc.publish_module == "Automotive System") {
+ frappe.set_route("query-report", "Kilometer Mapping", {
+ kilometer_mapping: frm.doc.kilometer_mapping,
+ });
}
-
},
after_save: function (frm) {
-
- frm.set_df_property('repair_checksheet_publish', 'hidden', 0)
- frm.refresh_field('repair_checksheet_publish')
-
+ frm.set_df_property("repair_checksheet_publish", "hidden", 0);
+ frm.refresh_field("repair_checksheet_publish");
},
vehicle: function (frm) {
- frm.set_df_property('vehicle', 'set_only_once', '1')
- frm.refresh_fields('vehicle')
- if (frm.doc.publish_module == 'Automotive System') {
-
+ frm.set_df_property("vehicle", "set_only_once", "1");
+ frm.refresh_fields("vehicle");
+ if (frm.doc.publish_module == "Automotive System") {
frappe.call({
- method: "smart_service.transactions.doctype.publish.publish.old_publish",
+ method:
+ "smart_service.transactions.doctype.publish.publish.old_publish",
async: false,
args: {
- "vehicle": frm.doc.vehicle,
- "language": frm.doc.language
+ vehicle: frm.doc.vehicle,
+ language: frm.doc.language,
},
callback: function (r) {
if (r.message) {
let vehicle = frm.doc.vehicle;
- cur_frm.doc.vehicle = '';
- cur_frm.doc.vehicle_status = '';
- cur_frm.refresh_field('vehicle');
- cur_frm.refresh_field('vehicle_status');
- frappe.msgprint("Already publish record " + r.message[0]['name'] + " created for " + vehicle + " vehicle. Please edit already available " + r.message[0]['publish_type'] + " publish!")
+ cur_frm.doc.vehicle = "";
+ cur_frm.doc.vehicle_status = "";
+ cur_frm.refresh_field("vehicle");
+ cur_frm.refresh_field("vehicle_status");
+ frappe.msgprint(
+ "Already publish record " +
+ r.message[0]["name"] +
+ " created for " +
+ vehicle +
+ " vehicle. Please edit already available " +
+ r.message[0]["publish_type"] +
+ " publish!"
+ );
}
- }
+ },
});
}
- if (frm.doc.publish_module == 'Repair service') {
-
- add_to_publish(frm)
+ if (frm.doc.publish_module == "Repair service") {
+ add_to_publish(frm);
+ }
+ if (
+ frm.doc.vehicle === undefined ||
+ (frm.doc.vehicle === null &&
+ frm.doc.publish_module == "Automotive System")
+ ) {
+ return;
}
- if (frm.doc.vehicle === undefined || frm.doc.vehicle === null && frm.doc.publish_module == 'Automotive System') { return; }
$("[data-fieldname=variant_mapping]").focus();
// if (frm.doc.vehicle) {
// frm.set_df_property('vehicle', 'read_only', 1);
// }
//other modules-Repair Checksheet
- if (frm.doc.publish_module == 'Repair service') {
- if (frm.doc.repair_checksheet_publish && frm.doc.repair_checksheet_publish.length > 0) {
- content_flag = 1
+ if (frm.doc.publish_module == "Repair service") {
+ if (
+ frm.doc.repair_checksheet_publish &&
+ frm.doc.repair_checksheet_publish.length > 0
+ ) {
+ content_flag = 1;
cur_frm.clear_table("repair_checksheet_publish");
- cur_frm.refresh_fields('repair_checksheet_publish');
-
+ cur_frm.refresh_fields("repair_checksheet_publish");
}
-
-
-
}
-
},
language: function (frm) {
- frm.doc.vehicle = ''
- frm.refresh_field('vehicle')
- frm.set_value('repair_checksheet_publish', '')
- frm.set_value('feature_finder_publish', '')
- frm.set_value('repiar_checksheet_publish_docs', '')
- frm.set_value('feature_finder_publish_docs', '')
-
- if (frm.doc.publish_module == 'Repair service' && frm.doc.vehicle) {
- add_to_publish(frm)
- if (frm.doc.repair_checksheet_publish && frm.doc.repair_checksheet_publish.length > 0) {
-
+ frm.doc.vehicle = "";
+ frm.refresh_field("vehicle");
+ frm.set_value("repair_checksheet_publish", "");
+ frm.set_value("feature_finder_publish", "");
+ frm.set_value("repiar_checksheet_publish_docs", "");
+ frm.set_value("feature_finder_publish_docs", "");
+
+ if (frm.doc.publish_module == "Repair service" && frm.doc.vehicle) {
+ add_to_publish(frm);
+ if (
+ frm.doc.repair_checksheet_publish &&
+ frm.doc.repair_checksheet_publish.length > 0
+ ) {
cur_frm.clear_table("repair_checksheet_publish");
- cur_frm.refresh_fields('repair_checksheet_publish');
-
+ cur_frm.refresh_fields("repair_checksheet_publish");
}
-
-
}
- if (frm.doc.publish_module == 'Feature Finder' && frm.doc.vehicle && frm.doc.variant_mapping) {
-
- if (frm.doc.feature_finder_publish && frm.doc.feature_finder_publish.length > 0) {
-
+ if (
+ frm.doc.publish_module == "Feature Finder" &&
+ frm.doc.vehicle &&
+ frm.doc.variant_mapping
+ ) {
+ if (
+ frm.doc.feature_finder_publish &&
+ frm.doc.feature_finder_publish.length > 0
+ ) {
cur_frm.clear_table("feature_finder_publish");
- cur_frm.refresh_fields('feature_finder_publish');
-
+ cur_frm.refresh_fields("feature_finder_publish");
}
-
-
}
- if (!lang_set_first_time && frm.doc.publish_module == 'Automotive System') {
- frappe.confirm('This will clear all the data, are you sure you want to proceed?',
+ if (!lang_set_first_time && frm.doc.publish_module == "Automotive System") {
+ frappe.confirm(
+ "This will clear all the data, are you sure you want to proceed?",
() => {
// action to perform if Yes is selected
- frm.set_value('variant_mapping', null);
- frm.set_value('variant_mapping_status', null);
- frm.set_value('system_mapping', null);
- frm.set_value('variant_mapping_assets', null);
- frm.set_value('publish_documents', null);
+ frm.set_value("variant_mapping", null);
+ frm.set_value("variant_mapping_status", null);
+ frm.set_value("system_mapping", null);
+ frm.set_value("variant_mapping_assets", null);
+ frm.set_value("publish_documents", null);
lang_set_first_time = false;
- }, () => {
+ },
+ () => {
// action to perform if No is selected
- });
-
+ }
+ );
}
- if (!lang_set_first_time && frm.doc.publish_module == 'Repair service') {
- frappe.confirm('This will clear all the data, are you sure you want to proceed?',
+ if (!lang_set_first_time && frm.doc.publish_module == "Repair service") {
+ frappe.confirm(
+ "This will clear all the data, are you sure you want to proceed?",
() => {
// action to perform if Yes is selected
- frm.set_value('feature_finder_publish', null);
+ frm.set_value("feature_finder_publish", null);
lang_set_first_time = false;
- }, () => {
+ },
+ () => {
// action to perform if No is selected
- });
-
-
+ }
+ );
}
- if (!lang_set_first_time && frm.doc.publish_module == 'Feature Finder') {
- frappe.confirm('This will clear all the data, are you sure you want to proceed?',
+ if (!lang_set_first_time && frm.doc.publish_module == "Feature Finder") {
+ frappe.confirm(
+ "This will clear all the data, are you sure you want to proceed?",
() => {
// action to perform if Yes is selected
- frm.set_value('feature_finder_publish', null);
- frm.set_value('variant_mapping', '')
+ frm.set_value("feature_finder_publish", null);
+ frm.set_value("variant_mapping", "");
lang_set_first_time = false;
- }, () => {
- // action to perform if No is selected
- });
-
- }
- else { lang_set_first_time = false; }
- },
- auto_version_update: function (frm) {
- if (frm.doc.vehicle && frm.doc.language && frm.doc.publish_type && frm.doc.publish_module == 'Automotive System') {
- frappe.call({
- method: 'smart_service.transactions.doctype.publish.publish.cal_ver',
- args: {
- vehicle: frm.doc.vehicle,
- lang: frm.doc.language,
- publish_type: frm.doc.publish_type,
- doc: frm.doc.name
- },
- callback: (r) => {
- frm.doc.version = r
- cur_frm.refresh_field('version')
},
- error: (r) => {
- // on error
+ () => {
+ // action to perform if No is selected
}
- });
- }
- else {
-
-
+ );
+ } else {
+ lang_set_first_time = false;
}
},
+ // auto_version_update: function (frm) {
+ // if (
+ // frm.doc.vehicle &&
+ // frm.doc.language &&
+ // frm.doc.publish_type &&
+ // frm.doc.publish_module == "Automotive System"
+ // ) {
+ // frappe.call({
+ // method: "smart_service.transactions.doctype.publish.publish.cal_ver",
+ // args: {
+ // vehicle: frm.doc.vehicle,
+ // lang: frm.doc.language,
+ // publish_type: frm.doc.publish_type,
+ // doc: frm.doc.name,
+ // },
+ // callback: (r) => {
+ // frm.doc.version = r;
+ // cur_frm.refresh_field("version");
+ // },
+ // error: (r) => {
+ // // on error
+ // },
+ // });
+ // } else {
+ // }
+ // },
publish_module: function (frm) {
- frm.doc.vehicle = ''
- frm.doc.variant_mapping = ''
- frm.doc.repair_checksheet_publish = ''
- frm.doc.feature_finder_publish = ''
- frm.set_value('feature_finder_publish_docs', '')
- frm.set_value('repiar_checksheet_publish_docs', '')
- frm.set_df_property('repiar_checksheet_publish_docs','hidden',1)
- frm.refresh_fields()
- if (frm.doc.publish_module == 'Repair service') {
- add_to_publish(frm)
+ frm.doc.vehicle = "";
+ frm.doc.variant_mapping = "";
+ frm.doc.repair_checksheet_publish = "";
+ frm.doc.feature_finder_publish = "";
+ frm.set_value("feature_finder_publish_docs", "");
+ frm.set_value("repiar_checksheet_publish_docs", "");
+ frm.set_df_property("repiar_checksheet_publish_docs", "hidden", 1);
+ frm.refresh_fields();
+ if (frm.doc.publish_module == "Repair service") {
+ add_to_publish(frm);
}
- if (frm.doc.publish_module == 'Automotive System') {
-
-
+ if (frm.doc.publish_module == "Automotive System") {
}
- if (frm.doc.publish_module == 'Feature Finder') {
- add_feature_finder(frm)
+ if (frm.doc.publish_module == "Feature Finder") {
+ add_feature_finder(frm);
}
-
-
- }
-
+ },
});
-frappe.ui.form.on('Publish_Temp Doc', {
+frappe.ui.form.on("Publish_Temp Doc", {
form_render(frm, cdt, cdn) {
- frm.fields_dict.system_mapping.grid.wrapper.find('.grid-delete-row').hide();
- frm.fields_dict.system_mapping.grid.wrapper.find('.grid-duplicate-row').hide();
- frm.fields_dict.system_mapping.grid.wrapper.find('.grid-move-row').hide();
- frm.fields_dict.system_mapping.grid.wrapper.find('.grid-append-row').hide();
- frm.fields_dict.system_mapping.grid.wrapper.find('.grid-insert-row-below').hide();
- frm.fields_dict.system_mapping.grid.wrapper.find('.grid-insert-row').hide();
+ frm.fields_dict.system_mapping.grid.wrapper.find(".grid-delete-row").hide();
+ frm.fields_dict.system_mapping.grid.wrapper
+ .find(".grid-duplicate-row")
+ .hide();
+ frm.fields_dict.system_mapping.grid.wrapper.find(".grid-move-row").hide();
+ frm.fields_dict.system_mapping.grid.wrapper.find(".grid-append-row").hide();
+ frm.fields_dict.system_mapping.grid.wrapper
+ .find(".grid-insert-row-below")
+ .hide();
+ frm.fields_dict.system_mapping.grid.wrapper.find(".grid-insert-row").hide();
},
-})
+});
function add_to_publish(frm) {
- cur_frm.clear_table("repair_checksheet_publish")
+ cur_frm.clear_table("repair_checksheet_publish");
cur_frm.refresh_fields();
- document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[4].setAttribute("style", "display:none;");
+ document
+ .getElementsByClassName("btn btn-xs btn-secondary grid-add-row")[4]
+ .setAttribute("style", "display:none;");
if (frm.doc.vehicle) {
frappe.call({
- method: "smart_service.transactions.doctype.publish.publish.get_service_repair",
- args: { vehicle: frm.doc.vehicle, language_label: frm.doc.language, publish_type: frm.doc.publish_type },
+ method:
+ "smart_service.transactions.doctype.publish.publish.get_service_repair",
+ args: {
+ vehicle: frm.doc.vehicle,
+ language_label: frm.doc.language,
+ publish_type: frm.doc.publish_type,
+ },
callback: function (r) {
-
if (r.message.length > 0) {
-
- var records = r.message
- records.map(v => {
+ var records = r.message;
+ records.map((v) => {
var childTable = cur_frm.add_child("repair_checksheet_publish");
- childTable.parent_name = v['name'];
- childTable.vehicle = v['vehicle'];
- childTable.language = v['language'];
- childTable.lang_myid = v['lang_myid'];
- childTable.display_order = v['display_order'];
- childTable.check_list_name = v['check_list_name'];
-
- childTable.active_status = v['active_status'];
- childTable.my_id = v['my_id'];
- childTable.lang_myid = v['lang_myid'];
- })
+ childTable.parent_name = v["name"];
+ childTable.vehicle = v["vehicle"];
+ childTable.language = v["language"];
+ childTable.lang_myid = v["lang_myid"];
+ childTable.display_order = v["display_order"];
+ childTable.check_list_name = v["check_list_name"];
+ childTable.active_status = v["active_status"];
+ childTable.my_id = v["my_id"];
+ childTable.lang_myid = v["lang_myid"];
+ });
//add to repair service published doc table
- if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish' && frm.doc.publish_module == 'Repair service') {
-
- frm.get_field('repair_checksheet_publish').grid.add_custom_button(__('Add to Publish'), function () {
- let added = 0;
- frm.doc.repair_checksheet_publish.forEach(row => {
- if (row.active_status == "Active" || row.active_status == "Inactive") {
- let dulicate = false;
- if (frm.doc.repiar_checksheet_publish_docs) {
- frm.doc.repiar_checksheet_publish_docs.forEach(publishrow => {
- if (row.parent_name == publishrow.parent_name) {
-
- dulicate = true;
- }
- });
- }
- if (dulicate === false) {
- let child = cur_frm.add_child("repiar_checksheet_publish_docs");
- child.vehicle = frm.doc.vehicle;
- child.parent_name = row.parent_name;
- child.language = row.language;
- child.check_list_name = row.check_list_name;
- child.active_status = row.active_status;
- // refresh_field("repiar_checksheet_publish_docs");
- added += 1;
- frm.set_df_property('repiar_checksheet_publish_docs', 'hidden', 0)
- refresh_field("repiar_checksheet_publish_docs");
- document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[4].setAttribute("style", "display:none;");
- document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[5].setAttribute("style", "display:none;");
- }
- else {
- frappe.msgprint(__(row.parent_name + 'Alraeady Added'))
+ if (
+ frm.doc.docstatus === 0 &&
+ frm.doc.publish_status == "To Publish" &&
+ frm.doc.publish_module == "Repair service"
+ ) {
+ frm
+ .get_field("repair_checksheet_publish")
+ .grid.add_custom_button(__("Add to Publish"), function () {
+ let added = 0;
+ frm.doc.repair_checksheet_publish.forEach((row) => {
+ if (
+ row.active_status == "Active" ||
+ row.active_status == "Inactive"
+ ) {
+ let dulicate = false;
+ if (frm.doc.repiar_checksheet_publish_docs) {
+ frm.doc.repiar_checksheet_publish_docs.forEach(
+ (publishrow) => {
+ if (row.parent_name == publishrow.parent_name) {
+ dulicate = true;
+ }
+ }
+ );
+ }
+ if (dulicate === false) {
+ let child = cur_frm.add_child(
+ "repiar_checksheet_publish_docs"
+ );
+ child.vehicle = frm.doc.vehicle;
+ child.parent_name = row.parent_name;
+ child.language = row.language;
+ child.check_list_name = row.check_list_name;
+ child.active_status = row.active_status;
+ // refresh_field("repiar_checksheet_publish_docs");
+ added += 1;
+ frm.set_df_property(
+ "repiar_checksheet_publish_docs",
+ "hidden",
+ 0
+ );
+ refresh_field("repiar_checksheet_publish_docs");
+ document
+ .getElementsByClassName(
+ "btn btn-xs btn-secondary grid-add-row"
+ )[4]
+ .setAttribute("style", "display:none;");
+ document
+ .getElementsByClassName(
+ "btn btn-xs btn-secondary grid-add-row"
+ )[5]
+ .setAttribute("style", "display:none;");
+ } else {
+ frappe.msgprint(__(row.parent_name + "Alraeady Added"));
+ }
}
-
+ });
+ if (added) {
+ frappe.msgprint(__(added + " Doc(s) Added"));
+ cur_frm.set_df_property(
+ "repair_checksheet_publish",
+ "read_only",
+ 1
+ );
+ cur_frm.refresh_field("repair_checksheet_publish");
+ } else if (added == 0) {
+ frappe.msgprint(__("No Doc Added"));
}
});
- if (added) {
- frappe.msgprint(__(added + " Doc(s) Added"));
- cur_frm.set_df_property('repair_checksheet_publish', 'read_only', 1)
- cur_frm.refresh_field("repair_checksheet_publish");
- }
- else if (added == 0) { frappe.msgprint(__("No Doc Added")); }
- });
- frm.fields_dict.repair_checksheet_publish.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
+ frm.fields_dict.repair_checksheet_publish.grid.grid_buttons
+ .find(".btn-custom")
+ .removeClass("btn-default")
+ .addClass("btn-primary");
}
- cur_frm.set_df_property('repair_checksheet_publish', 'hidden', 0)
+ cur_frm.set_df_property("repair_checksheet_publish", "hidden", 0);
cur_frm.refresh_field("repair_checksheet_publish");
- cur_frm.set_df_property('repiar_checksheet_publish_docs', 'read_only', 1)
- cur_frm.refresh_field("repiar_checksheet_publish_docs", 'read_only', 1);
-
- document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[4].setAttribute("style", "display:none;");
- document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[5].setAttribute("style", "display:none;");
-
-
+ cur_frm.set_df_property(
+ "repiar_checksheet_publish_docs",
+ "read_only",
+ 1
+ );
+ cur_frm.refresh_field(
+ "repiar_checksheet_publish_docs",
+ "read_only",
+ 1
+ );
+ document
+ .getElementsByClassName("btn btn-xs btn-secondary grid-add-row")[4]
+ .setAttribute("style", "display:none;");
+ document
+ .getElementsByClassName("btn btn-xs btn-secondary grid-add-row")[5]
+ .setAttribute("style", "display:none;");
}
- }
- })
-
-
+ },
+ });
}
-
}
function add_feature_finder(frm) {
-
- cur_frm.clear_table("feature_finder_publish")
+ cur_frm.clear_table("feature_finder_publish");
cur_frm.refresh_fields();
- var fin_add_btn = document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[3].setAttribute("style", "display:none;")
+ var fin_add_btn = document
+ .getElementsByClassName("btn btn-xs btn-secondary grid-add-row")[3]
+ .setAttribute("style", "display:none;");
frappe.call({
- method: "smart_service.transactions.doctype.publish.publish.get_feature_finder",
- args: { vehicle: frm.doc.vehicle, variant: frm.doc.variant_mapping, language_label: frm.doc.language, publish_type: frm.doc.publish_type },
+ method:
+ "smart_service.transactions.doctype.publish.publish.get_feature_finder",
+ args: {
+ vehicle: frm.doc.vehicle,
+ variant: frm.doc.variant_mapping,
+ language_label: frm.doc.language,
+ publish_type: frm.doc.publish_type,
+ },
callback: function (r) {
-
if (r.message.length > 0) {
- cur_frm.set_df_property('feature_finder_publish', 'hidden', 0)
- var records = r.message
- records.map(v => {
+ cur_frm.set_df_property("feature_finder_publish", "hidden", 0);
+ var records = r.message;
+ records.map((v) => {
var childTable = cur_frm.add_child("feature_finder_publish");
- childTable.parent1 = v['name'];
- childTable.vehicle = v['vehicle'];
- childTable.language = v['language'];
- childTable.variant = v['variant'];
- childTable.active_status = v['active_status'];
-
- })
+ childTable.parent1 = v["name"];
+ childTable.vehicle = v["vehicle"];
+ childTable.language = v["language"];
+ childTable.variant = v["variant"];
+ childTable.active_status = v["active_status"];
+ });
//add to repair service published doc table
- if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish' && frm.doc.publish_module == 'Feature Finder') {
-
- frm.get_field('feature_finder_publish').grid.add_custom_button(__('Add to Publish'), function () {
- let added = 0;
- frm.doc.feature_finder_publish.forEach(row => {
- if (row.active_status == "Active" || row.active_status == "Inactive") {
- let dulicate = false;
- if (frm.doc.feature_finder_publish_docs) {
- frm.doc.feature_finder_publish_docs.forEach(publishrow => {
- if (row.parent1 == publishrow.parent1) {
-
- dulicate = true;
- }
- });
- }
- if (dulicate === false) {
- let child = cur_frm.add_child("feature_finder_publish_docs");
- child.vehicle = frm.doc.vehicle;
- child.parent1 = row.parent1;
- child.language = row.language;
- child.variant = row.variant;
- child.active_status = row.active_status;
- added += 1;
- frm.set_df_property('feature_finder_publish_docs', 'hidden', 0)
- cur_frm.refresh_field("feature_finder_publish", 'read_only', 1);
- refresh_field("feature_finder_publish_docs");
- cur_frm.set_df_property("feature_finder_publish", 'read_only', 1);
- document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[4].setAttribute("style", "display:none;");
- document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[5].setAttribute("style", "display:none;");
-
- frm.fields_dict.repair_checksheet_publish.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
- }
- else {
- frappe.msgprint(__(row.parent1 + 'Alraeady Added'))
+ if (
+ frm.doc.docstatus === 0 &&
+ frm.doc.publish_status == "To Publish" &&
+ frm.doc.publish_module == "Feature Finder"
+ ) {
+ frm
+ .get_field("feature_finder_publish")
+ .grid.add_custom_button(__("Add to Publish"), function () {
+ let added = 0;
+ frm.doc.feature_finder_publish.forEach((row) => {
+ if (
+ row.active_status == "Active" ||
+ row.active_status == "Inactive"
+ ) {
+ let dulicate = false;
+ if (frm.doc.feature_finder_publish_docs) {
+ frm.doc.feature_finder_publish_docs.forEach(
+ (publishrow) => {
+ if (row.parent1 == publishrow.parent1) {
+ dulicate = true;
+ }
+ }
+ );
+ }
+ if (dulicate === false) {
+ let child = cur_frm.add_child(
+ "feature_finder_publish_docs"
+ );
+ child.vehicle = frm.doc.vehicle;
+ child.parent1 = row.parent1;
+ child.language = row.language;
+ child.variant = row.variant;
+ child.active_status = row.active_status;
+ added += 1;
+ frm.set_df_property(
+ "feature_finder_publish_docs",
+ "hidden",
+ 0
+ );
+ cur_frm.refresh_field(
+ "feature_finder_publish",
+ "read_only",
+ 1
+ );
+ refresh_field("feature_finder_publish_docs");
+ cur_frm.set_df_property(
+ "feature_finder_publish",
+ "read_only",
+ 1
+ );
+ document
+ .getElementsByClassName(
+ "btn btn-xs btn-secondary grid-add-row"
+ )[4]
+ .setAttribute("style", "display:none;");
+ document
+ .getElementsByClassName(
+ "btn btn-xs btn-secondary grid-add-row"
+ )[5]
+ .setAttribute("style", "display:none;");
+
+ frm.fields_dict.repair_checksheet_publish.grid.grid_buttons
+ .find(".btn-custom")
+ .removeClass("btn-default")
+ .addClass("btn-primary");
+ } else {
+ frappe.msgprint(__(row.parent1 + "Alraeady Added"));
+ }
+ cur_frm.refresh_field(
+ "feature_finder_publish_docs",
+ "read_only",
+ 1
+ );
}
- cur_frm.refresh_field("feature_finder_publish_docs", 'read_only', 1);
+ });
+ if (added) {
+ frappe.msgprint(__(added + " Doc(s) Added"));
+ cur_frm.set_df_property(
+ "feature_finder_publish",
+ "read_only",
+ 1
+ );
+ cur_frm.set_df_property(
+ "feature_finder_publish_docs",
+ "read_only",
+ 1
+ );
+ cur_frm.refresh_field("feature_finder_publish");
+ } else if (added == 0) {
+ frappe.msgprint(__("No Doc Added"));
}
});
- if (added) {
- frappe.msgprint(__(added + " Doc(s) Added"));
- cur_frm.set_df_property('feature_finder_publish', 'read_only', 1)
- cur_frm.set_df_property("feature_finder_publish_docs", 'read_only', 1);
- cur_frm.refresh_field("feature_finder_publish");
- }
- else if (added == 0) { frappe.msgprint(__("No Doc Added")); }
- });
- frm.fields_dict.feature_finder_publish.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
-
+ frm.fields_dict.feature_finder_publish.grid.grid_buttons
+ .find(".btn-custom")
+ .removeClass("btn-default")
+ .addClass("btn-primary");
}
-
-
- cur_frm.set_df_property('feature_finder_publish', 'hidden', 0)
+ cur_frm.set_df_property("feature_finder_publish", "hidden", 0);
cur_frm.refresh_field("feature_finder_publish");
- let find_add_btn = document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[3].setAttribute("style", "display:none;");
-
+ let find_add_btn = document
+ .getElementsByClassName("btn btn-xs btn-secondary grid-add-row")[3]
+ .setAttribute("style", "display:none;");
}
- }
- })
-
-
-
-
-}
\ No newline at end of file
+ },
+ });
+}
diff --git a/smart_service/transactions/doctype/publish/publish.json b/smart_service/transactions/doctype/publish/publish.json
index ee2b67c..68c7c06 100644
--- a/smart_service/transactions/doctype/publish/publish.json
+++ b/smart_service/transactions/doctype/publish/publish.json
@@ -319,7 +319,7 @@
"fieldname": "publish_module",
"fieldtype": "Select",
"label": "Module",
- "options": "\nAutomotive System\nFeature Finder\nRepair service",
+ "options": "Automotive System\nFeature Finder\nRepair service",
"reqd": 1
},
{
@@ -357,7 +357,7 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
- "modified": "2023-08-28 10:37:21.374827",
+ "modified": "2023-09-04 12:02:32.394888",
"modified_by": "Administrator",
"module": "Transactions",
"name": "Publish",
diff --git a/smart_service/transactions/doctype/publish/publish.py b/smart_service/transactions/doctype/publish/publish.py
index 7979ffb..3a70455 100644
--- a/smart_service/transactions/doctype/publish/publish.py
+++ b/smart_service/transactions/doctype/publish/publish.py
@@ -1,5 +1,7 @@
# Copyright (c) 2021, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
+from deepdiff import DeepDiff
+import pandas as pd
import copy
import sys
from html import unescape
@@ -13,7 +15,6 @@ from frappe.utils import logger
current_db_name = frappe.conf.get("db_name")
sys.tracebacklimit = 0
site_name = cstr(frappe.local.site)
-import pandas as pd
base_url = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public" + "/files" + "/json_files" + "/phase2"
@@ -22,12 +23,15 @@ frappe.utils.logger.set_log_level("DEBUG")
success_reponse = {"status": 1, "data": "", "message": ""}
failure_reponse = {"status": 0, "data": "", "error": ""}
module_name = 'feature_finder'
+exisitng_var = []
+new_variant = []
class Publish(Document):
def validate(self):
self.published_date = str(date.today())
self.published_by = frappe.session.user
+
# Selected variant and kilometer mapping details list
variant = []
for vm in self.get('publish_documents'):
@@ -37,10 +41,10 @@ class Publish(Document):
# variant.append(vm.variant_mapping)
if vm.variant_mapping not in variant:
variant.append(vm.variant_mapping)
- if self.publish_module=='Feature Finder' and self.feature_finder_publish_docs:
+ if self.publish_module == 'Feature Finder' and self.feature_finder_publish_docs:
for vm in self.get('feature_finder_publish_docs'):
- if vm.variant not in variant:
- variant.append(vm.variant)
+ if vm.variant not in variant:
+ variant.append(vm.variant)
self.variant_mapping_details = ''
self.kilometer_mapping_details = ''
@@ -85,7 +89,7 @@ class Publish(Document):
update_repair_published_docs(self)
update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
-
+
variant = self.variant_mapping_details.split('/n')
frappe.log_error('variant', str(variant))
@@ -95,56 +99,6 @@ class Publish(Document):
# update_publish_mapping(
# self.vehicle, v, self.language, self.publish_module)
- def onload1(self):
- current_db_name = frappe.conf.get("db_name")
- # To validate updated procedure status
- procedure_status = frappe.db.sql("""select p.name,p.update_procedure_status,pro.name,p.variant_mapping,p.system,p.sub_system,p.asset_category,
- p.item_category,p.variant,p.procedure_link,p.procedure_status,pro.name,pro.workflow_state
- from {0}.`tabPublish_Docs` as p,{0}.`tabProcedure` as pro where p.parent = '{1}' and
- p.procedure_link = pro.name and p.procedure_link is not null""".format(current_db_name, self.name), as_dict=1)
- l = len(procedure_status)
-
- if procedure_status and self.publish_status == "Published":
- for x in procedure_status:
- for y in self.get("publish_documents"):
- if y.procedure_link:
- if x.procedure_link == y.procedure_link and y.update_procedure_status != y.procedure_status:
- y.update_procedure_status = x.workflow_state
- frappe.db.sql("""update `tabPublish_Docs` set update_procedure_status = %s where parent = %s and procedure_link = %s ; """, (
- x.workflow_state, self.name, x.procedure_link))
- frappe.db.commit()
- if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status:
- y.update_procedure_status = x.workflow_state
- frappe.db.sql("""update `tabPublish_Docs` set update_procedure_status = %s where parent = %s and procedure_link = %s""", (
- x.workflow_state, self.name, x.procedure_link))
- frappe.db.commit()
- if y.procedure_status == "Publish Ready":
- if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status and not y.excluded_global:
- y.excluded_global = "1"
- if x.procedure_link == y.procedure_link and x.workflow_state != y.procedure_status and x.workflow_state == "Draft" and y.procedure_status != "Publish Ready":
- y.excluded_internal = "1"
- y.save()
- frappe.db.commit()
-
- # Update system and variant mapping ststus
- if self.publish_status == "Published" and self.publish_type == "Global":
- current_db_name = frappe.conf.get("db_name")
- global_publish = frappe.db.sql("""select name from {0}.`tabPublish` where global_publish = "{1}"; """.format(
- current_db_name, self.name), as_dict=True)
- for global_name in global_publish:
- update_mapping(self.variant_mapping, global_name.name)
-
- u_id = frappe.get_all(
- "User", filters={"name": frappe.session.user}, fields=["username"])
- if u_id:
- for i in u_id:
- name = i.username
- if not self.published_by and self.publish_status == "Published":
- self.published_by = str(name)
- frappe.db.set_value(
- "Publish", self.name, "published_by", str(name))
- frappe.db.commit()
-
def on_cancel(self):
# Published document should not allow to cancel
if self.publish_status == "Published":
@@ -204,25 +158,26 @@ def update_procedure(vehicle, lang, publish_type, doc):
# Generate Publish versions
-def update_publish_mapping(vehicle, variant, language, module,publish_type):
+def update_publish_mapping(vehicle, variant, language, module, publish_type):
frappe.set_user('Administrator')
if module == 'Repair service':
pub_data = frappe.db.get_list('Module Publish Mapping', filters={
"vehicle": vehicle,
"language": language,
- "publish_type":publish_type
+ "publish_type": publish_type
}, fields=['name'])
- if len(pub_data)>0:
+ if len(pub_data) > 0:
for d in pub_data:
if d['name']:
- frappe.db.sql(f"""UPDATE `tabModule Publish Mapping` set repairservice_check_sheet='1' and publish_type='1' where name ='{d['name']}'""",as_dict=1)
+ frappe.db.sql(
+ f"""UPDATE `tabModule Publish Mapping` set repairservice_check_sheet='1' and publish_type='1' where name ='{d['name']}'""", as_dict=1)
frappe.db.commit()
else:
pub_data = frappe.db.get_list('Module Publish Mapping', filters={
"vehicle": vehicle,
"variant": variant,
"language": language,
- "publish_type":publish_type
+ "publish_type": publish_type
}, fields=['name'])
if pub_data:
@@ -255,12 +210,18 @@ def update_publish_mapping(vehicle, variant, language, module,publish_type):
@frappe.whitelist()
-def cal_ver(vehicle, lang, publish_type, doc):
+def cal_ver(vehicle, lang, publish_type, doc, publish_module):
update_procedure(vehicle, lang, publish_type, doc)
current_db_name = frappe.conf.get("db_name")
doc = frappe.get_doc("Publish", doc)
- ver = frappe.db.sql("""select max(version) from `tabPublish` where vehicle = "{vehi}" and language = "{lang}";"""
- .format(vehi=vehicle, lang=lang))
+ if publish_module == 'Automotive System':
+ ver = frappe.db.sql("""select max(version) from `tabPublish` where vehicle = "{vehi}" and language = "{lang}"
+ and publish_module = 'Automotive System';"""
+ .format(vehi=vehicle, lang=lang))
+ else:
+ ver = frappe.db.sql("""select max(version) from `tabPublish` where vehicle = "{vehi}" and language = "{lang}"
+ and publish_module != 'Automotive System';"""
+ .format(vehi=vehicle, lang=lang))
v = 0.0
if publish_type == 'Global':
if ver[0][0] == None:
@@ -334,28 +295,28 @@ def global_publish(doc):
@frappe.whitelist()
-def generate_global_publish(name,module_name):
+def generate_global_publish(name, module_name):
try:
res = frappe.get_doc("Publish", name)
- if module_name=='Feature Finder':
+ if module_name == 'Feature Finder':
ret = frappe.get_doc({
"doctype": "Publish",
"vehicle": res.vehicle,
"publish_type": "Global",
"language": res.language,
- "variant_mapping_details":res.variant_mapping_details,
+ "variant_mapping_details": res.variant_mapping_details,
"publish_status": 'To Publish',
"release_description": res.release_description,
"publish_module": res.publish_module,
"feature_finder_publish_docs": res.feature_finder_publish_docs
})
elif module_name == 'Repair service':
- ret = frappe.get_doc({
+ ret = frappe.get_doc({
"doctype": "Publish",
"vehicle": res.vehicle,
"publish_type": "Global",
"language": res.language,
- "variant_mapping_details":res.variant_mapping,
+ "variant_mapping_details": res.variant_mapping,
"publish_status": 'To Publish',
"release_description": res.release_description,
"publish_module": res.publish_module,
@@ -583,19 +544,22 @@ def get_service_repair(vehicle,
select * from `tabRepair Service Mapping` where vehicle = '{vehicle}' and language='{language_label}' and published = 0;
''', as_dict=1)
return data
+
+
def create_df(data_set):
- feature_finder_tmp=json.dumps(data_set)
+ feature_finder_tmp = json.dumps(data_set)
df = pd.DataFrame(json.loads(feature_finder_tmp))
- filter_group=df.groupby('variant')
- keys=filter_group.groups.keys()
- res={}
+ filter_group = df.groupby('variant')
+ keys = filter_group.groups.keys()
+ res = {}
for i in keys:
- res[i]=(filter_group.get_group(i))
- res1={}
- for key,value in res.items():
- res1[key]=value.to_dict('records')
+ res[i] = (filter_group.get_group(i))
+ res1 = {}
+ for key, value in res.items():
+ res1[key] = value.to_dict('records')
return res1
+
@frappe.whitelist()
def get_feature_finder(vehicle=None, variant=None, language_label=None):
try:
@@ -715,13 +679,15 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
create_publish_folders(folder_url)
file_path = folder_url + "/" + publish_type + "/" + \
vehicle.replace(' ', '-') + '-feature_finder' + '.json'
- global_file_path=folder_url + "/" + "Global" + "/" + \
+ global_file_path = folder_url + "/" + 'Global' + "/" + \
vehicle.replace(' ', '-') + '-feature_finder' + '.json'
+
'''Append Published Data to Json'''
logger.info(
f'Repair Checksheet Data Append Start::{vehicle}-{language}-{publish_type}')
'''update existing global json file'''
- if os.path.isfile(file_path) and publish_type == 'Internal':
+ if os.path.isfile(global_file_path) and publish_type == 'Internal':
+
with open(global_file_path) as f:
published_data = json.load(f)
for i in parent:
@@ -731,21 +697,36 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
publish_repair_checksheet = 1
feature_finder_tmp.append(
feature_finder['data'][0])
- feature_finder_tmp=create_df(feature_finder_tmp)
- vehi_data = compare_get_data( {'data': published_data['data']}, {'data': feature_finder_tmp})
-
+ feature_finder_tmp = create_df(feature_finder_tmp)
+ vehi_data = compare_get_data({'data': published_data['data']}, {
+ 'data': feature_finder_tmp})
+ if vehi_data:
+ find_distinct = set(exisitng_var)
+ new_variant_name = [
+ x for x in new_variant if x not in find_distinct]
+ vehi_data = add_new_val(
+ vehi_data, new_variant_name, feature_finder_tmp)
+
elif os.path.isfile(file_path) and publish_type == 'Global':
+ frappe.msgprint(str('called'))
with open(global_file_path) as f:
published_data = json.load(f)
for i in parent:
feature_finder = feature_finder_data(vehicle, language,
- publish_type, i.parent1, i.variant)
+ publish_type, i.parent1, i.variant)
if feature_finder['status'] == 1:
publish_repair_checksheet = 1
feature_finder_tmp.append(
feature_finder['data'][0])
- feature_finder_tmp=create_df(feature_finder_tmp)
- vehi_data = compare_get_data( {'data': published_data['data']}, {'data': feature_finder_tmp})
+ feature_finder_tmp = create_df(feature_finder_tmp)
+ vehi_data = compare_get_data({'data': published_data['data']}, {
+ 'data': feature_finder_tmp})
+ if vehi_data:
+ find_distinct = set(exisitng_var)
+ new_variant_name = [
+ x for x in new_variant if x not in find_distinct]
+ vehi_data = add_new_val(
+ vehi_data, new_variant_name, feature_finder_tmp)
else:
for i in parent:
feature_finder = feature_finder_data(
@@ -761,8 +742,8 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
feature_finder_tmp = get_latest_data(
{'data': feature_finder_tmp}, {'data': []})
-
- vehi_data=create_df(feature_finder_tmp)
+
+ vehi_data = create_df(feature_finder_tmp)
""" Save publish file """
vehicle_data['data'] = vehi_data
@@ -803,11 +784,12 @@ def get_latest_data(prev_data, latest_data):
final_dic.update({d2: data_dic2[d2]})
final_list = list(final_dic.values())
-
+
return final_list
except Exception as e:
frappe.throw(str(e))
+
def compare_get_data(prev_data, latest_data):
try:
logger_file = 'compare'
@@ -815,60 +797,89 @@ def compare_get_data(prev_data, latest_data):
allow_site=True, file_count=100)
logger.info(
f"start compare data")
- final_dic={}
- final_dic=prev_data.copy()
-
- for key,value in final_dic["data"].items():
- for i in value:
- if i['active_status']=="Inactive":
- value.remove(i)
- for key,value in latest_data["data"].items():
- for i in value:
- if i['active_status']=="Inactive":
- value.remove(i)
- #compare old & new json
- for key,values in latest_data["data"].items():
+ final_dic = {}
+ final_dic = prev_data.copy()
+
+ # for key,value in latest_data["data"].items():
+ # for i in value:
+ # if i['active_status']=="Inactive":
+ # value.remove(i)
+ # compare old & new json
+ for key, values in latest_data["data"].items():
for i in latest_data["data"][key]:
- check_key({key:i},final_dic["data"],'')
+ check_key({key: i}, final_dic["data"], '')
+
+ # for key,value in final_dic["data"].items():
+ # for i in value:
+ # if i['active_status']=="Inactive":
+ # value.remove(i)
logger.info(
f"End of compare data"+str(final_dic['data']))
return final_dic['data']
-
-
+
except Exception as e:
logger.error(str(e))
- frappe.throw(str(e))
-
def check_key(key_name, old_data, type=None):
try:
- frappe.msgprint(str(key_name))
logger_file = 'check key'
logger = frappe.logger(logger_file,
allow_site=True, file_count=100)
logger.info(
f"start of key data")
- new_dict=[]
- for key,val in key_name.items():
+ new_dict_lst = []
+ new_dict = {}
+ for key, val in key_name.items():
if key in old_data:
- if val['name'] in old_data:
- for old_key,old_val in old_data.items():
- for i in old_val:
- if val['name'] in old_val :
- if old_key == key and val['name'] == i['name']:
- i.update(val)
- else:
- old_data[key].append(val)
-
+ for old_key, old_val in old_data.items():
+ for i in old_val:
+ if val['name'] in i.values():
+ exisitng_var.append(val['name'])
+ cmp = DeepDiff(i, val)
+ if cmp.get('values_changed'):
+ indx = old_data[key].index(i)
+ old_data[key][indx] = val
+ else:
+ indx = old_data[key].index(i)
+ old_data[key][indx] = val
+ else:
+ if val['name'] not in new_variant:
+ new_variant.append(val['name'])
+
else:
- new_dict.append(val)
- old_data[key]=new_dict
+ new_dict.update(val)
+ new_dict_lst.append(new_dict)
+ old_data[key] = new_dict_lst
+ # for key,val in key_name.items():
+ # if key in old_data:
+ # if val['name'] in old_data:
+ # for old_key,old_val in old_data.items():
+ # for i in old_val:
+ # if val['name'] in old_val :
+ # if old_key == key and val['name'] == i['name']:
+ # i.update(val)
+ # else:
+ # old_data[key].append(val)
+
+ # else:
+ # new_dict.append(val)
+ # old_data[key]=new_dict
logger.info(f"end of key data"+str(key_name))
except Exception as e:
logger.error(str(e))
return str(e)
+
+
+def add_new_val(old_data, new_val_variant, dt_new):
+ for dt_key, dt_val in dt_new.items():
+ for i in dt_val:
+ if i['name'] in new_val_variant:
+ old_data[dt_key].append(i)
+ return old_data
+
+
def repair_checksheet_data(vehicle=None, language=None,
publish_type=None, parent=None):
try:
@@ -880,6 +891,7 @@ def repair_checksheet_data(vehicle=None, language=None,
repair_service_details = frappe.db.sql(f"""select vehicle,vehicle_id,
name,language,check_list_name,
+ keywords,
active_status,display_order,my_id
from `tabRepair Service Mapping`
where vehicle = '{vehicle}'
@@ -917,6 +929,7 @@ def feature_finder_data(vehicle=None, language=None,
feature_finder_details = []
if language == 'en':
feature_finder_details = frappe.db.sql(f"""select ff.name,ff.vehicle,ff.vehicle_id,ff.variant,ff.variant_id,ff.language,
+ ff.keywords,
ff.features_names as feature_name,ff.feature_category,ff.display_order,ff.active_status,
ffm.feature_pdf as pdf from `tabFeature Finder` ff left join `tabFeature Finder Master` ffm on
ff.features_names = ffm.feature_name
@@ -927,6 +940,7 @@ def feature_finder_data(vehicle=None, language=None,
logger.info(feature_finder_details)
else:
feature_finder_details = frappe.db.sql(f"""select ff.name,ff.vehicle,ff.vehicle_id,ff.variant,ff.variant_id,ff.language,
+ ff.keywords,
ff.translated_feature_name as feature_name,ff.feature_category,
ff.display_order,ff.active_status,ffm.feature_pdf as pdf from `tabFeature Finder` ff
left join `tabFeature Finder Master` ffm on ff.features_names = ffm.feature_name
@@ -995,7 +1009,8 @@ def max_publish_new_module(doc):
def cal_ver_new_module(vehicle, lang, publish_type, doc):
current_db_name = frappe.conf.get("db_name")
doc = frappe.get_doc("Publish", doc)
- ver = frappe.db.sql("""select max(version) from `tabPublish` where vehicle = "{vehi}" and language = "{lang}" and publish_module!="Automotive System";"""
+ ver = frappe.db.sql("""select max(version) from `tabPublish` where vehicle = "{vehi}" and language = "{lang}" and
+ publish_module!="Automotive System";"""
.format(vehi=vehicle, lang=lang))
v = 0.0
if publish_type == 'Global':