added setup wizard 0.1
diff --git a/home/page/event_updates/event_updates.css b/home/page/event_updates/event_updates.css
index ed50351..a88fed4 100644
--- a/home/page/event_updates/event_updates.css
+++ b/home/page/event_updates/event_updates.css
@@ -14,4 +14,49 @@
font-size: 11px;
color: #FFF;
background-color: RED;
-}
\ No newline at end of file
+}
+
+div.setup-wizard {
+ display: none;
+ margin: 13px 0px;
+ background-color: #FED;
+ padding: 13px;
+}
+
+div.setup-wizard .header {
+ font-size: 12px;
+ font-weight: bold;
+ color: #322;
+ margin-bottom: 7px;
+}
+
+
+div.setup-wizard .percent-outer {
+ height: 17px;
+ background-color: #FFF;
+ border: 2px solid #322;
+}
+
+div.setup-wizard .percent-inner {
+ height: 17px;
+ background-color: GREEN;
+}
+
+div.setup-wizard .suggestion {
+ margin: 7px 0px;
+ color: #322;
+}
+
+div.setup-wizard .prev-next {
+ height: 13px;
+}
+
+div.setup-wizard .prev-next span {
+ display: none;
+ float: right;
+ margin-left: 13px;
+ color: #877;
+ font-size: 11px;
+}
+
+
diff --git a/home/page/event_updates/event_updates.js b/home/page/event_updates/event_updates.js
index 7ecfbdc..1574f53 100644
--- a/home/page/event_updates/event_updates.js
+++ b/home/page/event_updates/event_updates.js
@@ -24,8 +24,8 @@
wrapper.head = $a(wrapper.body, 'div');
wrapper.banner_area = $a(wrapper.head, 'div');
- wrapper.toolbar_area = $a(wrapper.head, 'div');
+ wrapper.setup_wizard_area = $a(wrapper.body, 'div', 'setup-wizard')
wrapper.system_message_area = $a(wrapper.body, 'div', '',
{marginBottom:'16px', padding:'8px', backgroundColor:'#FFD', border:'1px dashed #AA6', display:'none'})
@@ -612,7 +612,6 @@
// get values
$c_page('home', 'event_updates', 'get_status_details', user,
function(r,rt) {
-
home_status_bar.render(r.message);
// system_messages
@@ -622,6 +621,11 @@
// render online users
pscript.online_users_obj.render(r.message.online_users);
pscript.online_users = r.message.online_users;
+
+ // setup wizard
+ if(r.message.setup_status) {
+ new SetupWizard(r.message.setup_status)
+ }
}
);
}
@@ -633,7 +637,7 @@
var txt = $a(wrapper.system_message_area, 'div', '', {lineHeight:'1.6em'});
txt.innerHTML = msg;
- var span = $ln($a(wrapper.system_message_area, 'div'), 'Dismiss',
+ var span = $ln($a(wrapper.system_message_area, 'div', '', {textAlign:'right'}), 'Dismiss'.bold(),
function(me) {
me.set_working();
$c_obj('Home Control', 'dismiss_message', '', function(r,rt) {
@@ -729,3 +733,53 @@
if(!flag) alert(msg);
return flag;
}
+
+SetupWizard = function(status) {
+ var me = this;
+ $.extend(this, {
+ make: function(status) {
+ me.status = status;
+ me.wrapper = page_body.pages['Event Updates'].setup_wizard_area;
+ $ds(me.wrapper);
+ me.make_percent(status.percent);
+ me.make_suggestion(status.ret);
+ },
+ make_percent: function(percent) {
+ $a(me.wrapper, 'div', 'header', {}, 'Your setup is '+percent+'% complete');
+ var o = $a(me.wrapper, 'div', 'percent-outer');
+ $a(o, 'div', 'percent-inner', {width:percent + '%'});
+ },
+ make_suggestion: function(ret) {
+ me.suggest_area = $a(me.wrapper, 'div', 'suggestion');
+ if(me.status.ret.length>1) {
+ me.prev_next = $a(me.wrapper, 'div', 'prev-next');
+
+ // next
+ me.next = $a(me.prev_next, 'span', 'link_type', null, 'Next Suggestion',
+ function() { me.show_suggestion(me.cur_sugg+1) });
+
+ // prev
+ me.prev = $a(me.prev_next, 'span', 'link_type', null, 'Previous Suggestion',
+ function() { me.show_suggestion(me.cur_sugg-1) });
+
+ }
+ if(me.status.ret.length) {
+ me.show_suggestion(0);
+ } else {
+ me.suggest_area.innerHTML = 'Congratulations: '.bold() + 'You are now on your track... Good luck';
+ }
+ },
+ show_suggestion: function(idx) {
+ me.cur_sugg = idx;
+ me.suggest_area.innerHTML = 'What you can do next: '.bold() + me.status.ret[idx];
+
+ // show hide prev, next
+ if(me.status.ret.length>1) {
+ $dh(me.prev); $dh(me.next);
+ if(idx>0) $ds(me.prev);
+ if(idx<me.status.ret.length-1) $ds(me.next);
+ }
+ }
+ })
+ this.make(status);
+}
diff --git a/home/page/event_updates/event_updates.py b/home/page/event_updates/event_updates.py
index ce73cd1..6e811e7 100644
--- a/home/page/event_updates/event_updates.py
+++ b/home/page/event_updates/event_updates.py
@@ -35,11 +35,51 @@
if msg_id and msg_id != webnotes.conn.get_global('system_message_id', webnotes.session['user']):
msg = webnotes.conn.get_global('system_message')
- return {
+ ret = {
'user_count': len(online) or 0,
'unread_messages': get_unread_messages(),
'online_users': online or [],
'system_message':msg,
'is_trial': webnotes.conn.get_global('is_trial'),
- 'days_to_expiry': (webnotes.conn.get_global('days_to_expiry') or '0')
+ 'days_to_expiry': (webnotes.conn.get_global('days_to_expiry') or '0'),
+ 'setup_status': get_setup_status()
}
+ return ret
+
+def get_setup_status():
+ """
+ Returns the setup status of the current account
+ """
+ if cint(webnotes.conn.get_global('setup_done')):
+ return ''
+
+ percent = 20
+ ret = []
+
+ if not webnotes.conn.get_value('Personalize', None, 'header_html'):
+ ret.append('<a href="#!Form/Personalize/Personalize">Upload your company banner</a>')
+ else:
+ percent += 20
+
+ def check_type(doctype, ret, percent):
+ if not webnotes.conn.sql("select count(*) from tab%s" % doctype)[0][0]:
+ ret.append('''
+ <a href="#!Form/%(dt)s/New">
+ Create a new %(dt)s
+ </a> or
+ <a href="#!Import Data/%(dt)s">
+ Import from a spreadsheet</a>''' % {'dt':doctype})
+ else:
+ percent += 20
+ return ret, percent
+
+ ret, percent = check_type('Item', ret, percent)
+ ret, percent = check_type('Customer', ret, percent)
+ ret, percent = check_type('Supplier', ret, percent)
+
+ if percent==100:
+ webnotes.conn.set_global('setup_done', '1')
+ return ''
+
+ return {'ret': ret, 'percent': percent}
+
\ No newline at end of file
diff --git a/setup/doctype/personalize/personalize.py b/setup/doctype/personalize/personalize.py
index 6a15102..3264546 100644
--- a/setup/doctype/personalize/personalize.py
+++ b/setup/doctype/personalize/personalize.py
@@ -28,4 +28,4 @@
#
def set_html_from_image(self):
file_name = self.doc.file_list.split(',')[0]
- self.doc.header_html = '<div><img src="cgi-bin/getfile.cgi?name=' + file_name + '"/></div>'
+ self.doc.header_html = '<div><img style="max-height: 120px; max-width: 600px" src="index.cgi?cmd=get_file&fname=' + file_name + '"/></div>'
diff --git a/setup/page/import_data/import_data.html b/setup/page/import_data/import_data.html
index a4b30f4..5b30dd2 100644
--- a/setup/page/import_data/import_data.html
+++ b/setup/page/import_data/import_data.html
@@ -32,7 +32,7 @@
</tbody>
</table>
</form>
-<div style="background-color: #FFE; padding: 10px; margin: 10px;">
+<div style="background-color: #FFE; padding: 13px; margin: 17px;">
<h3>Data Import Guide</h3>
<ol>
<li>Get the template of the DocType for which you want to import in CSV (Comma seperated values) format.</li>
diff --git a/setup/page/import_data/import_data.js b/setup/page/import_data/import_data.js
index aa0bdbd..f1601e7 100644
--- a/setup/page/import_data/import_data.js
+++ b/setup/page/import_data/import_data.js
@@ -1,45 +1,55 @@
pscript['onload_Import Data'] = function() {
-
- //alert(profile.can_get_report);
+
+ //alert(profile.can_get_report);
- callback = function(r,rt) {
- var h = new PageHeader('di_header','Import Data','Tool to download template and upload data');
- var sel = $i('import_template');
- if(r.message){
- add_sel_options(sel, r.message);
- sel.onchange=function(){
- $i('child_tab_lst').innerHTML ='';
- if(sel.value != 'Select Master...'){
- $c_obj('Import Data Control','get_child_lst',sel.value,
- function(r,rt){
- var me = this;
- $y($i('child_tab_lst'),{backgroundColor:'#EEEEEE'})
- var desc = $a($i('child_tab_lst'), 'div', '', {padding:'8px'});
-
- desc.innerHTML = "<h4>Please click on following link(s) to download template.</h4>";
+ callback = function(r,rt) {
+ var h = new PageHeader('di_header','Import Data','Tool to download template and upload data');
+ var sel = $i('import_template');
+ if(r.message){
+ add_sel_options(sel, r.message);
+
+ // please collapse here when editing :)
+ sel.onchange=function(){
+ $i('child_tab_lst').innerHTML ='';
+ if(sel.value != 'Select Master...'){
+ $c_obj('Import Data Control','get_child_lst',sel.value,
+ function(r,rt){
+ var me = this;
+ $y($i('child_tab_lst'),{backgroundColor:'#EEEEEE', margin: '17px 17px', padding: '13px'})
+ var desc = $a($i('child_tab_lst'), 'div', '', {padding:'4px'});
+
+ desc.innerHTML = "<b>Download template(s) for importing "+sel_val(sel)+"</b>";
-
- var parent = $a($i('child_tab_lst'), 'div');
- var tab = make_table(parent,r.message.length,1,'100%',[],{padding:'8px',fontSize:'15px',borderCollapse: 'collapse'});
-
- for(var i=0;i<r.message.length;i++){
- var dt= $a($td(tab,i,0), 'span', 'link_type');
- dt.innerHTML = r.message[i];
- dt.nm = r.message[i];
-
-
- dt.onclick = function(){
- var ovr = $('input[name="overwrite"]:checked').length;
- window.location = outUrl + '?cmd=get_template&dt=' + this.nm + (ovr ? '&overwrite=1' : '');
- }
- }
- }
- );
- }
- }
- }
- }
- $c_obj('Import Data Control','get_master_lst','',callback);
-
+
+ var parent = $a($i('child_tab_lst'), 'div');
+ var tab = make_table(parent,r.message.length,1,'100%',[],{padding:'3px',borderCollapse: 'collapse'});
+
+ for(var i=0;i<r.message.length;i++){
+ var dt= $a($td(tab,i,0), 'span', 'link_type');
+ dt.innerHTML = r.message[i];
+ dt.nm = r.message[i];
+
+ dt.onclick = function(){
+ var ovr = $('input[name="overwrite"]:checked').length;
+ window.location = outUrl + '?cmd=get_template&dt=' + this.nm + (ovr ? '&overwrite=1' : '');
+ }
+ }
+ }
+ );
+ }
+ }
+ }
+
+ // set the default (if given in url)
+ if(window.location.hash) {
+ var to_set = window.location.hash.split('/').slice(-1)[0];
+ if(in_list(r.message, to_set)) {
+ sel.value = to_set;
+ sel.onchange();
+ }
+ }
+ }
+ $c_obj('Import Data Control','get_master_lst','',callback);
+
}