2014-02-14 10:17:51 +00:00
frappe . pages [ 'setup-wizard' ] . onload = function ( wrapper ) {
2013-10-08 12:29:11 +00:00
if ( sys _defaults . company ) {
2014-02-14 10:17:51 +00:00
frappe . set _route ( "desktop" ) ;
2013-10-08 12:29:11 +00:00
return ;
}
2013-10-07 12:52:29 +00:00
$ ( ".navbar:first" ) . toggle ( false ) ;
2013-10-08 12:29:11 +00:00
$ ( "body" ) . css ( { "padding-top" : "30px" } ) ;
2013-10-07 12:52:29 +00:00
2013-12-24 13:21:32 +00:00
var wizard _settings = {
2013-10-08 12:29:11 +00:00
page _name : "setup-wizard" ,
2013-10-04 12:18:05 +00:00
parent : wrapper ,
2013-10-08 12:29:11 +00:00
on _complete : function ( wiz ) {
var values = wiz . get _values ( ) ;
wiz . show _working ( ) ;
2014-02-14 10:17:51 +00:00
frappe . call ( {
2013-12-12 13:42:19 +00:00
method : "erpnext.setup.page.setup_wizard.setup_wizard.setup_account" ,
2013-10-08 12:29:11 +00:00
args : values ,
callback : function ( r ) {
if ( r . exc ) {
2014-02-14 10:17:51 +00:00
var d = msgprint ( frappe . _ ( "There were errors." ) ) ;
2013-10-08 12:29:11 +00:00
d . custom _onhide = function ( ) {
2014-02-14 10:17:51 +00:00
frappe . set _route ( erpnext . wiz . page _name , "0" ) ;
2013-10-08 12:29:11 +00:00
}
} else {
wiz . show _complete ( ) ;
setTimeout ( function ( ) {
if ( user === "Administrator" ) {
2014-02-14 10:17:51 +00:00
msgprint ( frappe . _ ( "Login with your new User ID" ) + ":" + values . email ) ;
2013-10-08 12:29:11 +00:00
setTimeout ( function ( ) {
2014-02-14 10:17:51 +00:00
frappe . app . logout ( ) ;
2013-10-08 12:29:11 +00:00
} , 2000 ) ;
} else {
2014-03-11 09:47:13 +00:00
window . location = "/desk" ;
2013-10-08 12:29:11 +00:00
}
} , 2000 ) ;
}
}
} )
} ,
2014-02-14 10:17:51 +00:00
title : frappe . _ ( "ERPNext Setup Guide" ) ,
2013-10-08 12:29:11 +00:00
welcome _html : ' < h1 class = "text-muted text-center" > < i class = "icon-magic" > < / i > < / h 1 > \
2014-02-14 10:17:51 +00:00
< h2 class = "text-center" > '+frappe._(' ERPNext Setup ')+' < / h 2 > \
2013-10-08 12:29:11 +00:00
< p class = "text-center" > ' +
2014-02-14 10:17:51 +00:00
frappe . _ ( 'Welcome to ERPNext. Over the next few minutes we will help you setup your ERPNext account. Try and fill in as much information as you have even if it takes a bit longer. It will save you a lot of time later. Good Luck!' ) +
2013-10-08 12:29:11 +00:00
'</p>' ,
working _html : ' < h3 class = "text-muted text-center" > < i class = "icon-refresh icon-spin" > < / i > < / h 3 > \
2014-02-14 10:17:51 +00:00
< h2 class = "text-center" > '+frappe._(' Setting up ... ')+' < / h 2 > \
2013-10-08 12:29:11 +00:00
< p class = "text-center" > ' +
2014-02-14 10:17:51 +00:00
frappe . _ ( 'Sit tight while your system is being setup. This may take a few moments.' ) +
2013-10-08 12:29:11 +00:00
'</p>' ,
complete _html : ' < h1 class = "text-muted text-center" > < i class = "icon-thumbs-up" > < / i > < / h 1 > \
2014-02-14 10:17:51 +00:00
< h2 class = "text-center" > '+frappe._(' Setup Complete ! ')+' < / h 2 > \
2013-10-08 12:29:11 +00:00
< p class = "text-center" > ' +
2014-02-14 10:17:51 +00:00
frappe . _ ( 'Your setup is complete. Refreshing...' ) +
2013-10-08 12:29:11 +00:00
'</p>' ,
2013-10-04 12:18:05 +00:00
slides : [
// User
{
2014-02-14 10:17:51 +00:00
title : frappe . _ ( "The First User: You" ) ,
2013-10-07 12:52:29 +00:00
icon : "icon-user" ,
2013-10-04 12:18:05 +00:00
fields : [
2014-02-14 10:17:51 +00:00
{ "fieldname" : "first_name" , "label" : frappe . _ ( "First Name" ) , "fieldtype" : "Data" ,
2013-12-24 13:21:32 +00:00
reqd : 1 } ,
2014-02-14 10:17:51 +00:00
{ "fieldname" : "last_name" , "label" : frappe . _ ( "Last Name" ) , "fieldtype" : "Data" ,
2013-12-24 13:21:32 +00:00
reqd : 1 } ,
2014-02-14 10:17:51 +00:00
{ "fieldname" : "email" , "label" : frappe . _ ( "Email Id" ) , "fieldtype" : "Data" ,
2013-12-24 13:21:32 +00:00
reqd : 1 , "description" : "Your Login Id" , "options" : "Email" } ,
2014-02-14 10:17:51 +00:00
{ "fieldname" : "password" , "label" : frappe . _ ( "Password" ) , "fieldtype" : "Password" ,
2013-12-24 13:21:32 +00:00
reqd : 1 } ,
{ fieldtype : "Attach Image" , fieldname : "attach_profile" ,
label : "Attach Your Profile..." } ,
2013-10-04 12:18:05 +00:00
] ,
2014-02-14 10:17:51 +00:00
help : frappe . _ ( 'The first user will become the System Manager (you can change that later).' ) ,
2013-10-08 12:29:11 +00:00
onload : function ( slide ) {
if ( user !== "Administrator" ) {
slide . form . fields _dict . password . $wrapper . toggle ( false ) ;
2013-10-18 10:37:47 +00:00
slide . form . fields _dict . email . $wrapper . toggle ( false ) ;
2014-02-14 10:17:51 +00:00
slide . form . fields _dict . first _name . set _input ( frappe . boot . profile . first _name ) ;
slide . form . fields _dict . last _name . set _input ( frappe . boot . profile . last _name ) ;
2013-12-24 13:21:32 +00:00
2013-10-08 12:29:11 +00:00
delete slide . form . fields _dict . email ;
delete slide . form . fields _dict . password ;
}
}
2013-10-04 12:18:05 +00:00
} ,
2013-12-24 13:21:32 +00:00
2013-10-04 12:18:05 +00:00
// Organization
{
2014-02-14 10:17:51 +00:00
title : frappe . _ ( "The Organization" ) ,
2013-10-07 12:52:29 +00:00
icon : "icon-building" ,
2013-10-04 12:18:05 +00:00
fields : [
2014-02-14 10:17:51 +00:00
{ fieldname : 'company_name' , label : frappe . _ ( 'Company Name' ) , fieldtype : 'Data' , reqd : 1 ,
2013-10-04 12:18:05 +00:00
placeholder : 'e.g. "My Company LLC"' } ,
2014-02-14 10:17:51 +00:00
{ fieldname : 'company_abbr' , label : frappe . _ ( 'Company Abbreviation' ) , fieldtype : 'Data' ,
2013-10-04 12:18:05 +00:00
placeholder : 'e.g. "MC"' , reqd : 1 } ,
2013-11-25 14:21:18 +00:00
{ fieldname : 'fy_start_date' , label : 'Financial Year Start Date' , fieldtype : 'Date' ,
description : 'Your financial year begins on' , reqd : 1 } ,
{ fieldname : 'fy_end_date' , label : 'Financial Year End Date' , fieldtype : 'Date' ,
description : 'Your financial year ends on' , reqd : 1 } ,
2014-02-14 10:17:51 +00:00
{ fieldname : 'company_tagline' , label : frappe . _ ( 'What does it do?' ) , fieldtype : 'Data' ,
2013-10-08 12:29:11 +00:00
placeholder : 'e.g. "Build tools for builders"' , reqd : 1 } ,
2013-10-04 12:18:05 +00:00
] ,
2014-02-14 10:17:51 +00:00
help : frappe . _ ( 'The name of your company for which you are setting up this system.' ) ,
2013-10-04 12:18:05 +00:00
onload : function ( slide ) {
slide . get _input ( "company_name" ) . on ( "change" , function ( ) {
var parts = slide . get _input ( "company_name" ) . val ( ) . split ( " " ) ;
var abbr = $ . map ( parts , function ( p ) { return p ? p . substr ( 0 , 1 ) : null } ) . join ( "" ) ;
slide . get _input ( "company_abbr" ) . val ( abbr . toUpperCase ( ) ) ;
2014-02-14 10:17:51 +00:00
} ) . val ( frappe . boot . control _panel . company _name || "" ) . trigger ( "change" ) ;
2013-11-26 11:59:51 +00:00
slide . get _input ( "fy_start_date" ) . on ( "change" , function ( ) {
var year _end _date =
2014-02-14 10:17:51 +00:00
frappe . datetime . add _days ( frappe . datetime . add _months ( slide . get _input ( "fy_start_date" ) . val ( ) , 12 ) , - 1 ) ;
2013-11-26 11:59:51 +00:00
slide . get _input ( "fy_end_date" ) . val ( year _end _date ) ;
} ) ;
2013-10-04 12:18:05 +00:00
}
} ,
2013-12-24 13:21:32 +00:00
2013-10-04 12:18:05 +00:00
// Country
{
2014-02-14 10:17:51 +00:00
title : frappe . _ ( "Country, Timezone and Currency" ) ,
2013-10-07 12:52:29 +00:00
icon : "icon-flag" ,
2013-10-04 12:18:05 +00:00
fields : [
2014-02-14 10:17:51 +00:00
{ fieldname : 'country' , label : frappe . _ ( 'Country' ) , reqd : 1 ,
2013-10-04 12:18:05 +00:00
options : "" , fieldtype : 'Select' } ,
2014-02-14 10:17:51 +00:00
{ fieldname : 'currency' , label : frappe . _ ( 'Default Currency' ) , reqd : 1 ,
2013-10-04 12:18:05 +00:00
options : "" , fieldtype : 'Select' } ,
2014-02-14 10:17:51 +00:00
{ fieldname : 'timezone' , label : frappe . _ ( 'Time Zone' ) , reqd : 1 ,
2013-10-04 12:18:05 +00:00
options : "" , fieldtype : 'Select' } ,
] ,
2014-02-14 10:17:51 +00:00
help : frappe . _ ( 'Select your home country and check the timezone and currency.' ) ,
2013-10-04 12:18:05 +00:00
onload : function ( slide , form ) {
2014-02-14 10:17:51 +00:00
frappe . call ( {
method : "frappe.country_info.get_country_timezone_info" ,
2013-10-04 12:18:05 +00:00
callback : function ( data ) {
erpnext . country _info = data . message . country _info ;
erpnext . all _timezones = data . message . all _timezones ;
slide . get _input ( "country" ) . empty ( )
. add _options ( [ "" ] . concat ( keys ( erpnext . country _info ) . sort ( ) ) ) ;
slide . get _input ( "currency" ) . empty ( )
2014-02-14 10:17:51 +00:00
. add _options ( frappe . utils . unique ( [ "" ] . concat ( $ . map ( erpnext . country _info ,
2013-10-04 12:18:05 +00:00
function ( opts , country ) { return opts . currency ; } ) ) ) . sort ( ) ) ;
slide . get _input ( "timezone" ) . empty ( )
. add _options ( [ "" ] . concat ( erpnext . all _timezones ) ) ;
}
} )
2013-12-24 13:21:32 +00:00
2013-10-04 12:18:05 +00:00
slide . get _input ( "country" ) . on ( "change" , function ( ) {
var country = slide . get _input ( "country" ) . val ( ) ;
var $timezone = slide . get _input ( "timezone" ) ;
$timezone . empty ( ) ;
// add country specific timezones first
if ( country ) {
var timezone _list = erpnext . country _info [ country ] . timezones || [ ] ;
$timezone . add _options ( timezone _list . sort ( ) ) ;
slide . get _input ( "currency" ) . val ( erpnext . country _info [ country ] . currency ) ;
}
// add all timezones at the end, so that user has the option to change it to any timezone
$timezone . add _options ( [ "" ] . concat ( erpnext . all _timezones ) ) ;
} ) ;
}
} ,
2013-12-24 13:21:32 +00:00
2013-10-04 12:18:05 +00:00
// Logo
{
2013-10-07 12:52:29 +00:00
icon : "icon-bookmark" ,
2014-02-14 10:17:51 +00:00
title : frappe . _ ( "Logo and Letter Heads" ) ,
help : frappe . _ ( 'Upload your letter head and logo - you can edit them later.' ) ,
2013-10-07 12:52:29 +00:00
fields : [
{ fieldtype : "Attach Image" , fieldname : "attach_letterhead" , label : "Attach Letterhead..." } ,
{ fieldtype : "Attach Image" , fieldname : "attach_logo" , label : "Attach Logo..." } ,
] ,
2013-10-04 12:18:05 +00:00
} ,
2013-12-24 13:21:32 +00:00
2013-10-04 12:18:05 +00:00
// Taxes
{
2013-10-07 12:52:29 +00:00
icon : "icon-money" ,
2014-02-14 10:17:51 +00:00
"title" : frappe . _ ( "Add Taxes" ) ,
"help" : frappe . _ ( "List your tax heads (e.g. VAT, Excise) (upto 3) and their standard rates. This will create a standard template, you can edit and add more later." ) ,
2013-12-24 13:21:32 +00:00
"fields" : [ ] ,
2013-10-07 12:52:29 +00:00
} ,
2013-11-19 09:42:10 +00:00
// Customers
{
icon : "icon-group" ,
2014-02-14 10:17:51 +00:00
"title" : frappe . _ ( "Your Customers" ) ,
"help" : frappe . _ ( "List a few of your customers. They could be organizations or individuals." ) ,
2013-12-24 13:21:32 +00:00
"fields" : [ ] ,
2013-11-19 09:42:10 +00:00
} ,
2013-12-24 13:21:32 +00:00
2013-10-07 12:52:29 +00:00
// Items to Sell
{
icon : "icon-barcode" ,
2014-02-14 10:17:51 +00:00
"title" : frappe . _ ( "Your Products or Services" ) ,
"help" : frappe . _ ( "List your products or services that you sell to your customers. Make sure to check the Item Group, Unit of Measure and other properties when you start." ) ,
2013-12-24 13:21:32 +00:00
"fields" : [ ] ,
2013-10-07 12:52:29 +00:00
} ,
2013-11-19 09:42:10 +00:00
// Suppliers
{
icon : "icon-group" ,
2014-02-14 10:17:51 +00:00
"title" : frappe . _ ( "Your Suppliers" ) ,
"help" : frappe . _ ( "List a few of your suppliers. They could be organizations or individuals." ) ,
2013-12-24 13:21:32 +00:00
"fields" : [ ] ,
2013-11-19 09:42:10 +00:00
} ,
2013-10-07 12:52:29 +00:00
// Items to Buy
{
icon : "icon-barcode" ,
2014-02-14 10:17:51 +00:00
"title" : frappe . _ ( "Products or Services You Buy" ) ,
"help" : frappe . _ ( "List a few products or services you buy from your suppliers or vendors. If these are same as your products, then do not add them." ) ,
2013-12-24 13:21:32 +00:00
"fields" : [ ] ,
2013-10-07 12:52:29 +00:00
} ,
2013-10-04 12:18:05 +00:00
]
2013-12-24 13:21:32 +00:00
}
// taxes
for ( var i = 1 ; i < 4 ; i ++ ) {
wizard _settings . slides [ 4 ] . fields = wizard _settings . slides [ 4 ] . fields . concat ( [
{ fieldtype : "Data" , fieldname : "tax_" + i , label : "Tax " + 1 , placeholder : "e.g. VAT" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Data" , fieldname : "tax_rate_i" , label : "Rate (%)" , placeholder : "e.g. 5" } ,
{ fieldtype : "Section Break" } ,
] )
}
// customers
for ( var i = 1 ; i < 6 ; i ++ ) {
wizard _settings . slides [ 5 ] . fields = wizard _settings . slides [ 5 ] . fields . concat ( [
{ fieldtype : "Data" , fieldname : "customer_" + i , label : "Customer " + i ,
placeholder : "Customer Name" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Data" , fieldname : "customer_contact_" + i ,
label : "Contact" , placeholder : "Contact Name" } ,
{ fieldtype : "Section Break" }
] )
}
2013-12-27 08:13:40 +00:00
// products
2013-12-24 13:21:32 +00:00
for ( var i = 1 ; i < 6 ; i ++ ) {
wizard _settings . slides [ 6 ] . fields = wizard _settings . slides [ 6 ] . fields . concat ( [
2013-12-27 08:13:40 +00:00
{ fieldtype : "Data" , fieldname : "item_" + i , label : "Item " + i ,
2013-12-24 13:21:32 +00:00
placeholder : "A Product or Service" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Attach" , fieldname : "item_img_" + i , label : "Attach Image..." } ,
{ fieldtype : "Section Break" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , label : "Group" , fieldname : "item_group_" + i ,
options : [ "Products" , "Services" , "Raw Material" , "Sub Assemblies" ] } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_uom_" + i , label : "UOM" ,
options : [ "Unit" , "Nos" , "Box" , "Pair" , "Kg" , "Set" , "Hour" , "Minute" ] } ,
{ fieldtype : "Section Break" }
] )
}
for ( var i = 1 ; i < 6 ; i ++ ) {
wizard _settings . slides [ 7 ] . fields = wizard _settings . slides [ 7 ] . fields . concat ( [
{ fieldtype : "Data" , fieldname : "supplier_" + i , label : "Supplier " + i ,
placeholder : "Supplier Name" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Data" , fieldname : "supplier_contact_" + i ,
label : "Contact" , placeholder : "Contact Name" } ,
{ fieldtype : "Section Break" }
] )
}
for ( var i = 1 ; i < 6 ; i ++ ) {
wizard _settings . slides [ 8 ] . fields = wizard _settings . slides [ 8 ] . fields . concat ( [
{ fieldtype : "Data" , fieldname : "item_buy_" + i , label : "Item " + i ,
placeholder : "A Product or Service" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Section Break" } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_buy_group_" + i , label : "Group" ,
options : [ "Raw Material" , "Consumable" , "Sub Assemblies" , "Services" , "Products" ] } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Select" , fieldname : "item_buy_uom_" + i , label : "UOM" ,
options : [ "Unit" , "Nos" , "Box" , "Pair" , "Kg" , "Set" , "Hour" , "Minute" ] } ,
{ fieldtype : "Section Break" } ,
] )
}
2014-02-14 10:17:51 +00:00
erpnext . wiz = new frappe . wiz . Wizard ( wizard _settings )
2013-10-04 12:18:05 +00:00
}
2014-02-14 10:17:51 +00:00
frappe . pages [ 'setup-wizard' ] . onshow = function ( wrapper ) {
if ( frappe . get _route ( ) [ 1 ] )
erpnext . wiz . show ( frappe . get _route ( ) [ 1 ] ) ;
2013-10-04 12:18:05 +00:00
}
2014-02-14 10:17:51 +00:00
frappe . provide ( "frappe.wiz" ) ;
2013-10-04 12:18:05 +00:00
2014-02-14 10:17:51 +00:00
frappe . wiz . Wizard = Class . extend ( {
2013-10-04 12:18:05 +00:00
init : function ( opts ) {
$ . extend ( this , opts ) ;
2013-10-08 12:29:11 +00:00
this . slides = this . slides ;
2013-10-04 12:18:05 +00:00
this . slide _dict = { } ;
2013-10-08 12:29:11 +00:00
this . show _welcome ( ) ;
} ,
get _message : function ( html ) {
2013-11-02 09:17:11 +00:00
return $ ( repl ( ' < div class = "panel panel-default" > \
2013-10-08 12:29:11 +00:00
< div class = "panel-body" style = "padding: 40px;" > % ( html ) s < / d i v > \
< / d i v > ' , { h t m l : h t m l } ) )
} ,
show _welcome : function ( ) {
if ( this . $welcome )
return ;
var me = this ;
this . $welcome = this . get _message ( this . welcome _html +
2014-02-14 10:17:51 +00:00
'<br><p class="text-center"><button class="btn btn-primary">' + frappe . _ ( "Start" ) + '</button></p>' )
2013-10-08 12:29:11 +00:00
. appendTo ( this . parent ) ;
this . $welcome . find ( ".btn" ) . click ( function ( ) {
me . $welcome . toggle ( false ) ;
me . welcomed = true ;
2014-02-14 10:17:51 +00:00
frappe . set _route ( me . page _name , "0" ) ;
2013-10-08 12:29:11 +00:00
} )
this . current _slide = { "$wrapper" : this . $welcome } ;
} ,
show _working : function ( ) {
this . hide _current _slide ( ) ;
2014-02-14 10:17:51 +00:00
frappe . set _route ( this . page _name ) ;
2013-10-08 12:29:11 +00:00
this . current _slide = { "$wrapper" : this . get _message ( this . working _html ) . appendTo ( this . parent ) } ;
} ,
show _complete : function ( ) {
this . hide _current _slide ( ) ;
this . current _slide = { "$wrapper" : this . get _message ( this . complete _html ) . appendTo ( this . parent ) } ;
2013-10-04 12:18:05 +00:00
} ,
show : function ( id ) {
2013-10-08 12:29:11 +00:00
if ( ! this . welcomed ) {
2014-02-14 10:17:51 +00:00
frappe . set _route ( this . page _name ) ;
2013-10-08 12:29:11 +00:00
return ;
}
2013-10-04 12:18:05 +00:00
id = cint ( id ) ;
if ( this . current _slide && this . current _slide . id === id )
return ;
if ( ! this . slide _dict [ id ] ) {
2014-02-14 10:17:51 +00:00
this . slide _dict [ id ] = new frappe . wiz . WizardSlide ( $ . extend ( this . slides [ id ] , { wiz : this , id : id } ) ) ;
2013-10-04 12:18:05 +00:00
this . slide _dict [ id ] . make ( ) ;
}
2013-10-08 12:29:11 +00:00
this . hide _current _slide ( ) ;
2013-10-04 12:18:05 +00:00
this . current _slide = this . slide _dict [ id ] ;
this . current _slide . $wrapper . toggle ( true ) ;
} ,
2013-10-08 12:29:11 +00:00
hide _current _slide : function ( ) {
if ( this . current _slide ) {
this . current _slide . $wrapper . toggle ( false ) ;
this . current _slide = null ;
}
} ,
get _values : function ( ) {
var values = { } ;
$ . each ( this . slide _dict , function ( id , slide ) {
$ . extend ( values , slide . values )
} )
return values ;
}
2013-10-04 12:18:05 +00:00
} ) ;
2014-02-14 10:17:51 +00:00
frappe . wiz . WizardSlide = Class . extend ( {
2013-10-04 12:18:05 +00:00
init : function ( opts ) {
$ . extend ( this , opts ) ;
} ,
make : function ( ) {
var me = this ;
2013-11-02 09:17:11 +00:00
this . $wrapper = $ ( repl ( ' < div class = "panel panel-default" > \
2013-12-24 13:21:32 +00:00
< div class = "panel-heading" > \
< div class = "panel-title row" > \
2014-02-19 07:13:16 +00:00
< div class = "col-sm-8" > < h3 style = "margin: 0px;" > \
< i class = "%(icon)s text-muted" > < / i > % ( t i t l e ) s < / h 3 > < / d i v > \
< div class = "col-sm-4 text-right" > < a class = "prev-btn hide btn btn-default" > Previous < / a > \
< a class = "next-btn hide btn btn-primary" > Next < / a > \
< a class = "complete-btn hide btn btn-primary" > < b > Complete Setup < / b > < / a > \
2013-12-24 13:21:32 +00:00
< / d i v > \
< / d i v > \
< / d i v > \
2013-10-04 12:18:05 +00:00
< div class = "panel-body" > \
< div class = "progress" > \
< div class = "progress-bar" style = "width: %(width)s%" > < / d i v > \
< / d i v > \
2013-11-02 09:17:11 +00:00
< br > \
2013-10-04 12:18:05 +00:00
< div class = "row" > \
2013-11-02 09:17:11 +00:00
< div class = "col-sm-8 form" > < / d i v > \
< div class = "col-sm-4 help" > \
2013-10-08 12:29:11 +00:00
< p class = "text-muted" > % ( help ) s < / p > \
< / d i v > \
2013-10-04 12:18:05 +00:00
< / d i v > \
< hr > \
< div class = "footer" > < / d i v > \
< / d i v > \
2013-10-07 12:52:29 +00:00
< / d i v > ' , { h e l p : t h i s . h e l p , t i t l e : t h i s . t i t l e , m a i n _ t i t l e : t h i s . w i z . t i t l e , s t e p : t h i s . i d + 1 ,
width : ( flt ( this . id + 1 ) / ( this . wiz . slides . length + 1 ) ) * 100 , icon : this . icon } ) )
2013-10-04 12:18:05 +00:00
. appendTo ( this . wiz . parent ) ;
this . body = this . $wrapper . find ( ".form" ) [ 0 ] ;
if ( this . fields ) {
2014-02-14 10:17:51 +00:00
this . form = new frappe . ui . FieldGroup ( {
2013-10-04 12:18:05 +00:00
fields : this . fields ,
2013-10-07 12:52:29 +00:00
body : this . body ,
no _submit _on _enter : true
2013-10-04 12:18:05 +00:00
} ) ;
this . form . make ( ) ;
} else {
$ ( this . body ) . html ( this . html )
}
if ( this . id > 0 ) {
2013-12-24 13:21:32 +00:00
this . $prev = this . $wrapper . find ( '.prev-btn' ) . removeClass ( "hide" )
2013-10-08 12:29:11 +00:00
. click ( function ( ) {
2014-02-14 10:17:51 +00:00
frappe . set _route ( me . wiz . page _name , me . id - 1 + "" ) ;
2013-10-08 12:29:11 +00:00
} )
2013-12-24 13:21:32 +00:00
. css ( { "margin-right" : "10px" } ) ;
2013-10-04 12:18:05 +00:00
}
if ( this . id + 1 < this . wiz . slides . length ) {
2013-12-24 13:21:32 +00:00
this . $next = this . $wrapper . find ( '.next-btn' ) . removeClass ( "hide" )
2013-10-08 12:29:11 +00:00
. click ( function ( ) {
me . values = me . form . get _values ( ) ;
if ( me . values === null )
return ;
2014-02-14 10:17:51 +00:00
frappe . set _route ( me . wiz . page _name , me . id + 1 + "" ) ;
2013-10-08 12:29:11 +00:00
} )
2013-10-04 12:18:05 +00:00
} else {
2013-12-24 13:21:32 +00:00
this . $complete = this . $wrapper . find ( '.complete-btn' ) . removeClass ( "hide" )
2013-10-08 12:29:11 +00:00
. click ( function ( ) {
me . values = me . form . get _values ( ) ;
if ( me . values === null )
return ;
me . wiz . on _complete ( me . wiz ) ;
2013-12-24 13:21:32 +00:00
} )
2013-10-04 12:18:05 +00:00
}
if ( this . onload ) {
this . onload ( this ) ;
}
} ,
get _input : function ( fn ) {
return this . form . get _input ( fn ) ;
}
} )