@ -170,14 +170,24 @@ function custom_tab_html(frm){
ret += '</div>'
res . append ( ret )
res . append ( ` <style>.custom_tab{border:1px solid var(--table-border-color);}.nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link.active {background-color:lavender !important;}.nav-tabs {
border - bottom : none ! important ; } . specification_bl { margin : 10 px ; } . main { border : 1 px solid var ( -- table - border - color ) ; margin : 15 px 0 px 15 px 0 px } . spec_custom_add { margin : 10 px 0 px 0 px 0 px } < / s t y l e > ` )
$ ( res ) . find ( '.main' ) . append ( ` <div class="specification_bl"></div> ` )
$ ( res ) . find ( '.main' ) . append ( ` <div class="feature_imgbl"></div> ` )
$ ( res ) . find ( '.main' ) . append ( ` <div class="feature_contbl"></div> ` )
res . append ( ` <style>.custom_tab{border:1px solid var(--table-border-color);}.nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link.active {background-color:lavender !important;}.nav-tabs {
border - bottom : none ! important ; } . feature_contbl { margin : 10 px ; } . specification_bl { margin : 10 px ; } . feature_imgbl { margin : 10 px ; } . main { border : 1 px solid var ( -- table - border - color ) ; margin : 15 px 0 px 15 px 0 px } . spec_custom_add { margin : 10 px 0 px 0 px 0 px } < / s t y l e > ` )
var specification = ""
var feature_finder_images = ""
var feature_finder_content = ""
specification = frm . doc . specification . filter ( o => o . feature_type == "SOP" )
feature_finder_images = frm . doc . feature_finder_images . filter ( o => o . feature_type == "SOP" )
feature_finder_content = frm . doc . feature_finder_content . filter ( o => o . feature_type == "SOP" )
var spec_dialog_value = ""
var image_dialog_value = ""
var content_dialog_value = ""
var nav_spec = { }
nav_spec . feature_type = "SOP"
all_tabs ( )
@ -188,11 +198,16 @@ function custom_tab_html(frm){
nav_spec . feature_type = "SOP"
nav_spec . post_vin_cutoff_name = ""
specification = frm . doc . specification . filter ( o => o . feature_type == $ ( this ) [ 0 ] . id )
feature_finder_images = frm . doc . feature_finder_images . filter ( o => o . feature_type == $ ( this ) [ 0 ] . id )
feature_finder_content = frm . doc . feature_finder_content . filter ( o => o . feature_type == $ ( this ) [ 0 ] . id )
}
else {
nav_spec . feature_type = "Post Vin CutOff"
nav_spec . post_vin_cutoff_name = $ ( this ) [ 0 ] . id
specification = frm . doc . specification . filter ( o => o . post_vin_cutoff_name == $ ( this ) [ 0 ] . id )
feature_finder_images = frm . doc . feature_finder_images . filter ( o => o . post_vin_cutoff_name == $ ( this ) [ 0 ] . id )
console . log ( feature_finder_images , "---feature_finder_images" )
feature_finder_content = frm . doc . feature_finder_content . filter ( o => o . post_vin_cutoff_name == $ ( this ) [ 0 ] . id )
}
all_tabs ( )
@ -201,6 +216,9 @@ function custom_tab_html(frm){
function all_tabs ( ) {
//heading
var spec_custom_dt = ""
spec_custom_dt += ` <label class="control-label">Specification</label><table class="table table-bordered table-editable" style='margin:0px !important'>
< thead >
@ -219,11 +237,50 @@ function custom_tab_html(frm){
spec_custom_dt += "<tbody>"
var image_custom_dt = ""
image_custom_dt += ` <label class="control-label">Feature Finder Images</label><table class="table table-bordered table-editable" style='margin:0px !important'>
< thead >
< tr >
< th style = "width: 7%;" class = "feature_image" > < input type = "checkbox" id = "imgcheckAll" ' class="grid-row-check pull-left"><span class=' image_check ' > No < / s p a n > < / t h >
< th > Image < / t h >
< th > Active Status < / t h >
< th > Feature Type < / t h >
< th > Post Vin CutOff Name < / t h >
< th > < a > < svg class = "icon icon-sm" style = "filter: opacity(0.5)" >
< use class = "" href = "#icon-setting-gear" > < / u s e >
< / s v g > < / a > < / t h >
< / t r >
< / t h e a d > `
image_custom_dt += "<tbody>"
var content_custom_dt = ""
content_custom_dt += ` <label class="control-label">Feature Finder Content</label><table class="table table-bordered table-editable" style='margin:0px !important'>
< thead >
< tr >
< th style = "width: 7%;" class = "feature_content" > < input type = "checkbox" id = "contentcheckAll" ' class="grid-row-check pull-left"><span class=' content_check ' > No < / s p a n > < / t h >
< th > Content < / t h >
< th > Active Status < / t h >
< th > Feature Type < / t h >
< th > Post Vin CutOff Name < / t h >
< th > < a > < svg class = "icon icon-sm" style = "filter: opacity(0.5)" >
< use class = "" href = "#icon-setting-gear" > < / u s e >
< / s v g > < / a > < / t h >
< / t r >
< / t h e a d > `
content_custom_dt += "<tbody>"
//end heading
//list
var specification_count = 0
if ( specification . length > 0 ) {
specification . map ( val => {
specification_count += 1
// spec_custom_dt += '<tr draggable="true" ondragstart="dragstartFunction(event)" ondragover="dragovertFunction(event)">'
spec_custom_dt += '<tr>'
spec_custom_dt += '<td style="width: 7%;"><input id=' + val . name + ' type="checkbox" class="check grid-row-check pull-left"><span class="spec_check">' + specification_count + '</span></td>'
spec_custom_dt += '<td style="width: 7%;" id="count "><input id=' + val . name + ' type="checkbox" class="spec check grid-row-check pull-left"><span class="spec_check">' + specification_count + '</span></td>'
spec_custom_dt += '<td>' + val . specification + '</td>'
spec_custom_dt += '<td>' + val . value + '</td>'
spec_custom_dt += '<td>' + val . active_status + '</td>'
@ -239,37 +296,216 @@ function custom_tab_html(frm){
spec_custom_dt += '</tr>'
} )
} else {
spec_custom_dt += '<tr><td></td><td style="text-align:center">No Records Found</td></tr>'
}
var image_count = 0
if ( feature_finder_images . length ) {
feature_finder_images . map ( val => {
image_count += 1
// spec_custom_dt += '<tr draggable="true" ondragstart="dragstartFunction(event)" ondragover="dragovertFunction(event)">'
image_custom_dt += '<tr>'
image_custom_dt += '<td style="width: 7%;" id="count"><input id=' + val . name + ' type="checkbox" class="imagecheck grid-row-check pull-left"><span class="image_check">' + image_count + '</span></td>'
image_custom_dt += '<td>' + val . image + '</td>'
image_custom_dt += '<td>' + val . active_status + '</td>'
image_custom_dt += '<td>' + val . feature_type + '</td>'
if ( val . post_vin_cutoff_name ) {
image_custom_dt += '<td>' + val . post_vin_cutoff_name + '</td>'
}
else {
image_custom_dt += '<td> </td>'
}
image_custom_dt += '<td id=' + val . name + ' class="image_edit_row"><a><svg class="icon icon-xs" style=""><use class="" href="#icon-edit"></use></svg>Edit</a></td>'
image_custom_dt += '</tr>'
} )
} else {
image_custom_dt += '<tr><td></td><td style="text-align:center">No Records Found</td></tr>'
}
var content_count = 0
if ( feature_finder_content . length ) {
feature_finder_content . map ( val => {
content_count += 1
// spec_custom_dt += '<tr draggable="true" ondragstart="dragstartFunction(event)" ondragover="dragovertFunction(event)">'
content_custom_dt += '<tr>'
content_custom_dt += '<td style="width: 7%;" id="count"><input id=' + val . name + ' type="checkbox" class="contentcheck grid-row-check pull-left"><span class="content_check">' + content_count + '</span></td>'
content_custom_dt += '<td>' + val . content + '</td>'
content_custom_dt += '<td>' + val . active_status + '</td>'
content_custom_dt += '<td>' + val . feature_type + '</td>'
if ( val . post_vin_cutoff_name ) {
content_custom_dt += '<td>' + val . post_vin_cutoff_name + '</td>'
}
else {
content_custom_dt += '<td> </td>'
}
content_custom_dt += '<td id=' + val . name + ' class="content_edit_row"><a><svg class="icon icon-xs" style=""><use class="" href="#icon-edit"></use></svg>Edit</a></td>'
content_custom_dt += '</tr>'
} )
} else {
content_custom_dt += '<tr><td></td><td style="text-align:center">No Records Found</td></tr>'
}
//list end
//buttons
spec_custom_dt += '</tbody>'
spec_custom_dt += '</table>'
spec_custom_dt += '<button class="btn btn-xs btn-secondary grid-add-row spec_custom_delete">Delete</button>'
spec_custom_dt += '<button class="btn btn-xs btn-secondary grid-add-row spec_custom_add">Add Row</button>'
spec_custom_dt += '<button class="btn btn-xs btn-secondary grid-add-row spec_custom_save">Save</button>'
image_custom_dt += '</tbody>'
image_custom_dt += '</table>'
image_custom_dt += '<button class="btn btn-xs btn-secondary grid-add-row image_custom_delete">Delete</button>'
image_custom_dt += '<button class="btn btn-xs btn-secondary grid-add-row image_custom_add">Add Row</button>'
image_custom_dt += '<button class="btn btn-xs btn-secondary grid-add-row image_custom_save">Save</button>'
content_custom_dt += '</tbody>'
content_custom_dt += '</table>'
content_custom_dt += '<button class="btn btn-xs btn-secondary grid-add-row content_custom_delete">Delete</button>'
content_custom_dt += '<button class="btn btn-xs btn-secondary grid-add-row content_custom_add">Add Row</button>'
content_custom_dt += '<button class="btn btn-xs btn-secondary grid-add-row content_custom_save">Save</button>'
//button end
//append
spec_custom_dt += '</div>'
image_custom_dt += '</div>'
content_custom_dt += '</div>'
$ ( res ) . find ( '.specification_bl' ) . empty ( )
$ ( res ) . find ( '.specification_bl' ) . append ( spec_custom_dt )
$ ( res ) . append ( ` <style>.spec_check{padding:0px 5px 0px 5px !important}.spec_custom_delete{margin:10px 10px 0px 0px;background-color:red !important;color:#fff !important;display:none}</style> ` )
// $(res).append(spec_custom_dt)
$ ( res ) . find ( '.feature_imgbl' ) . empty ( )
$ ( res ) . find ( '.feature_imgbl' ) . append ( image_custom_dt )
$ ( res ) . find ( '.feature_contbl' ) . empty ( )
$ ( res ) . find ( '.feature_contbl' ) . append ( content_custom_dt )
$ ( res ) . append ( ` <style>.spec_check{padding:0px 5px 0px 5px !important}.spec_custom_save{display:none}.spec_custom_delete{margin:10px 10px 0px 0px;background-color:red !important;color:#fff !important;display:none}</style> ` )
$ ( res ) . append ( ` <style>.image_check{padding:0px 5px 0px 5px !important}.image_custom_save{display:none}.image_custom_delete{margin:10px 10px 0px 0px;background-color:red !important;color:#fff !important;display:none}
. image_custom_add { margin : 10 px 0 px 0 px 0 px < / s t y l e > ` )
$ ( res ) . append ( ` <style>.content_check{padding:0px 5px 0px 5px !important}.content_custom_save{display:none}.content_custom_delete{margin:10px 10px 0px 0px;background-color:red !important;color:#fff !important;display:none}
. content_custom_add { margin : 10 px 0 px 0 px 0 px < / s t y l e > ` )
//append end
//add button
$ ( res ) . find ( '.feature_imgbl' ) . find ( '.image_custom_add' ) . click ( function ( event ) {
image_dialog_value = ""
image_dialog_value = nav_spec
image_dialog_view ( )
} )
$ ( res ) . find ( '.specification_bl' ) . find ( '.spec_custom_add' ) . click ( function ( event ) {
spec_dialog_value = ""
spec_dialog_value = nav_spec
spec_dialog_view ( )
} )
$ ( res ) . find ( '.feature_contbl' ) . find ( '.content_custom_add' ) . click ( function ( event ) {
content_dialog_value = ""
content_dialog_value = nav_spec
content_dialog_view ( )
} )
//end add button
//edit button
$ ( res ) . find ( '.feature_imgbl' ) . find ( '.image_edit_row' ) . click ( function ( event ) {
image_dialog_value = frm . doc . feature_finder_images . filter ( o => o . name == $ ( this ) [ 0 ] . id ) [ 0 ]
image_dialog_view ( )
} )
$ ( res ) . find ( '.specification_bl' ) . find ( '.spec_edit_row' ) . click ( function ( event ) {
spec_dialog_value = frm . doc . specification . filter ( o => o . name == $ ( this ) [ 0 ] . id ) [ 0 ]
spec_dialog_view ( )
} )
$ ( res ) . find ( '.feature_contbl' ) . find ( '.content_edit_row' ) . click ( function ( event ) {
content_dialog_value = frm . doc . feature_finder_content . filter ( o => o . name == $ ( this ) [ 0 ] . id ) [ 0 ]
content_dialog_view ( )
} )
//end edit button
//delete all button
$ ( res ) . find ( '.feature_imgbl' ) . find ( '.feature_image' ) . find ( 'input[type=checkbox]' ) . change ( function ( ) {
$ ( ".imagecheck" ) . prop ( 'checked' , $ ( this ) . prop ( 'checked' ) ) ;
if ( this . checked ) {
$ ( res ) . find ( '.feature_imgbl' ) . find ( '.image_custom_delete' ) . css ( "display" , "inline-block" )
} else {
$ ( res ) . find ( '.feature_imgbl' ) . find ( '.image_custom_delete' ) . css ( "display" , "None" )
}
} )
$ ( res ) . find ( '.specification_bl' ) . find ( '.specifiction' ) . find ( 'input[type=checkbox]' ) . change ( function ( ) {
$ ( ".check" ) . prop ( 'checked' , $ ( this ) . prop ( 'checked' ) ) ;
$ ( ".speccheck" ) . prop ( 'checked' , $ ( this ) . prop ( 'checked' ) ) ;
if ( this . checked ) {
$ ( res ) . find ( '.specification_bl' ) . find ( '.spec_custom_delete' ) . css ( "display" , "inline-block" )
} else {
$ ( res ) . find ( '.specification_bl' ) . find ( '.spec_custom_delete' ) . css ( "display" , "None" )
}
} )
$ ( res ) . find ( '.feature_contbl' ) . find ( '.feature_content' ) . find ( 'input[type=checkbox]' ) . change ( function ( ) {
$ ( ".contentcheck" ) . prop ( 'checked' , $ ( this ) . prop ( 'checked' ) ) ;
if ( this . checked ) {
$ ( res ) . find ( '.feature_contbl' ) . find ( '.content_custom_delete' ) . css ( "display" , "inline-block" )
} else {
$ ( res ) . find ( '.feature_contbl' ) . find ( '.content_custom_delete' ) . css ( "display" , "None" )
}
} )
//end delete all button
//individual delete button
$ ( res ) . find ( '.feature_imgbl' ) . find ( '.imagecheck' ) . change ( function ( ) {
if ( this . checked ) {
$ ( res ) . find ( '.feature_imgbl' ) . find ( '.image_custom_delete' ) . css ( "display" , "inline-block" )
} else {
$ ( res ) . find ( '.feature_imgbl' ) . find ( '.image_custom_delete' ) . css ( "display" , "None" )
}
} )
$ ( res ) . find ( '.specification_bl' ) . find ( '.speccheck' ) . change ( function ( ) {
if ( this . checked ) {
$ ( res ) . find ( '.specification_bl' ) . find ( '.spec_custom_delete' ) . css ( "display" , "inline-block" )
} else {
$ ( res ) . find ( '.specification_bl' ) . find ( '.spec_custom_delete' ) . css ( "display" , "None" )
}
} )
$ ( res ) . find ( '.feature_contbl' ) . find ( '.contentcheck' ) . change ( function ( ) {
if ( this . checked ) {
$ ( res ) . find ( '.feature_contbl' ) . find ( '.content_custom_delete' ) . css ( "display" , "inline-block" )
} else {
$ ( res ) . find ( '.feature_contbl' ) . find ( '.content_custom_delete' ) . css ( "display" , "None" )
}
} )
//end individual delete button
//delete function
$ ( res ) . find ( '.specification_bl' ) . find ( '.spec_custom_delete' ) . click ( function ( event ) {
var arr = [ ]
$ ( res ) . find ( '.specification_bl' ) . find ( "input[type=checkbox]" ) . each ( function ( ) {
@ -279,7 +515,10 @@ function custom_tab_html(frm){
arr . push ( self . attr ( "id" ) ) ;
}
} ) ;
if ( arr [ 0 ] == "checkAll" ) {
arr = arr . slice ( 1 )
}
console . log ( arr , "-------------------" )
frappe . call ( {
method : "smart_service.phase_2.doctype.feature_finder.feature_finder.delete_spec_data" ,
@ -295,6 +534,63 @@ function custom_tab_html(frm){
} )
} )
$ ( res ) . find ( '.feature_imgbl' ) . find ( '.image_custom_delete' ) . click ( function ( event ) {
var arr = [ ]
$ ( res ) . find ( '.feature_imgbl' ) . find ( "input[type=checkbox]" ) . each ( function ( ) {
var self = $ ( this ) ;
if ( self . is ( ':checked' ) ) {
console . log ( self . attr ( "id" ) , "sdcdcd" )
arr . push ( self . attr ( "id" ) ) ;
}
} ) ;
if ( arr [ 0 ] == "checkAll" ) {
arr = arr . slice ( 1 )
}
console . log ( arr , "-------------------" )
frappe . call ( {
method : "smart_service.phase_2.doctype.feature_finder.feature_finder.delete_image_data" ,
args : {
values : arr
} ,
callback : function ( r ) {
console . log ( r . message . status , '-rmessage' )
if ( r . message . status == "success" ) {
cur_frm . reload_doc ( )
}
}
} )
} )
$ ( res ) . find ( '.feature_contbl' ) . find ( '.content_custom_delete' ) . click ( function ( event ) {
var arr = [ ]
$ ( res ) . find ( '.feature_contbl' ) . find ( "input[type=checkbox]" ) . each ( function ( ) {
var self = $ ( this ) ;
if ( self . is ( ':checked' ) ) {
console . log ( self . attr ( "id" ) , "sdcdcd" )
arr . push ( self . attr ( "id" ) ) ;
}
} ) ;
if ( arr [ 0 ] == "checkAll" ) {
arr = arr . slice ( 1 )
}
console . log ( arr , "-------------------" )
frappe . call ( {
method : "smart_service.phase_2.doctype.feature_finder.feature_finder.delete_content_data" ,
args : {
values : arr
} ,
callback : function ( r ) {
console . log ( r . message . status , '-rmessage' )
if ( r . message . status == "success" ) {
cur_frm . reload_doc ( )
}
}
} )
} )
//delete function end
}
function spec_dialog_view ( ) {
@ -317,7 +613,7 @@ function custom_tab_html(frm){
default : spec_dialog_value . specification
} ,
{
label : 'Valuee ' ,
label : 'Value' ,
fieldname : 'value' ,
fieldtype : 'Data' ,
default : spec_dialog_value . value
@ -342,6 +638,7 @@ function custom_tab_html(frm){
fieldtype : 'Data' ,
default : spec_dialog_value . post_vin_cutoff_name ,
depends_on : "eval:doc.feature_type=='Post Vin CutOff'" ,
} ,
] ,
// size: 'small', // small, large, extra-large
@ -371,6 +668,146 @@ function custom_tab_html(frm){
}
function image_dialog_view ( ) {
let spec_dia = new frappe . ui . Dialog ( {
title : 'Enter details' ,
fields : [
{
label : 'Name' ,
fieldname : 'name' ,
fieldtype : 'Data' ,
default : image_dialog_value . name ,
hidden : 1
} ,
{
label : 'Image' ,
fieldname : 'image' ,
fieldtype : 'Attach' ,
} ,
{
label : 'Active Status' ,
fieldname : 'active_status' ,
fieldtype : 'Select' ,
options : "Active\nInactive" ,
default : image_dialog_value . active_status
} ,
{
label : 'Feature Type' ,
fieldname : 'feature_type' ,
fieldtype : 'Data' ,
default : image_dialog_value . feature_type ,
read_only : 1
} ,
{
label : 'Post Vin Cutoff Name' ,
fieldname : 'post_vin_cutoff_name' ,
fieldtype : 'Data' ,
default : image_dialog_value . post_vin_cutoff_name ,
depends_on : "eval:doc.feature_type=='Post Vin CutOff'" ,
read_only : 1
} ,
] ,
// size: 'small', // small, large, extra-large
primary_action_label : 'Submit' ,
primary_action ( values ) {
console . log ( values , "values" ) ;
if ( values ) {
console . log ( values , "---values" )
frappe . call ( {
method : "smart_service.phase_2.doctype.feature_finder.feature_finder.insert_image_data" ,
args : {
doc_name : frm . doc . name ,
values : values
} ,
callback : function ( r ) {
console . log ( r . message . status , '-rmessage' )
if ( r . message . status == "success" ) {
cur_frm . reload_doc ( )
}
}
} )
}
spec_dia . hide ( ) ;
}
} ) ;
console . log ( spec_dia , "spec_dia" )
spec_dia . show ( ) ;
}
function content_dialog_view ( ) {
let spec_dia = new frappe . ui . Dialog ( {
title : 'Enter details' ,
fields : [
{
label : 'Name' ,
fieldname : 'name' ,
fieldtype : 'Data' ,
default : content_dialog_value . name ,
hidden : 1
} ,
{
label : 'Content' ,
fieldname : 'content' ,
fieldtype : 'Data' ,
default : content_dialog_value . content ,
} ,
{
label : 'Active Status' ,
fieldname : 'active_status' ,
fieldtype : 'Select' ,
options : "Active\nInactive" ,
default : content_dialog_value . active_status
} ,
{
label : 'Feature Type' ,
fieldname : 'feature_type' ,
fieldtype : 'Data' ,
default : content_dialog_value . feature_type ,
read_only : 1
} ,
{
label : 'Post Vin Cutoff Name' ,
fieldname : 'post_vin_cutoff_name' ,
fieldtype : 'Data' ,
default : content_dialog_value . post_vin_cutoff_name ,
depends_on : "eval:doc.feature_type=='Post Vin CutOff'" ,
read_only : 1
} ,
] ,
// size: 'small', // small, large, extra-large
primary_action_label : 'Submit' ,
primary_action ( values ) {
console . log ( values , "values" ) ;
if ( values ) {
console . log ( values , "---values" )
frappe . call ( {
method : "smart_service.phase_2.doctype.feature_finder.feature_finder.insert_content_data" ,
args : {
doc_name : frm . doc . name ,
values : values
} ,
callback : function ( r ) {
console . log ( r . message . status , '-rmessage' )
if ( r . message . status == "success" ) {
cur_frm . reload_doc ( )
}
}
} )
}
spec_dia . hide ( ) ;
}
} ) ;
console . log ( spec_dia , "spec_dia" )
spec_dia . show ( ) ;
}
// $("#specification").click(function(){