Bläddra i källkod

Merge branch 'responsive' of github.com:webnotes/wnframework into responsive

Conflicts:
	public/js/legacy/widgets/form/form.js
version-14
Anand Doshi 12 år sedan
förälder
incheckning
0e588aeb69
54 ändrade filer med 754 tillägg och 1597 borttagningar
  1. +11
    -11
      core/doctype/docfield/docfield.txt
  2. +7
    -0
      core/doctype/doctype/doctype.js
  3. +1
    -0
      core/doctype/doctype_mapper/doctype_mapper.py
  4. +4
    -1
      core/doctype/letter_head/letter_head.py
  5. +8
    -20
      public/build.json
  6. +120
    -33
      public/css/bootstrap.css
  7. +0
    -75
      public/css/legacy/dialog.css
  8. +0
    -7
      public/css/legacy/fields.css
  9. +0
    -32
      public/css/legacy/sidebar.css
  10. +80
    -5
      public/css/ui/common.css
  11. +0
    -1
      public/html/server.py
  12. +0
    -0
      public/js/legacy/datatype.js
  13. +0
    -0
      public/js/legacy/datetime.js
  14. +0
    -0
      public/js/legacy/dom.js
  15. +1
    -1
      public/js/legacy/handler.js
  16. +0
    -0
      public/js/legacy/loaders.js
  17. +0
    -0
      public/js/legacy/printElement.js
  18. +0
    -94
      public/js/legacy/webpage/page_header.js
  19. +0
    -231
      public/js/legacy/webpage/search.js
  20. +0
    -145
      public/js/legacy/widgets/dialog.js
  21. +0
    -62
      public/js/legacy/widgets/export_query.js
  22. +2
    -2
      public/js/legacy/widgets/form/clientscriptAPI.js
  23. +6
    -20
      public/js/legacy/widgets/form/form.js
  24. +36
    -49
      public/js/legacy/widgets/form/print_format.js
  25. +0
    -285
      public/js/legacy/widgets/tags.js
  26. +0
    -210
      public/js/legacy/widgets/tree.js
  27. +0
    -88
      public/js/legacy/wn/widgets/form/sidebar.js
  28. +0
    -151
      public/js/legacy/wn/widgets/page_sidebar.js
  29. +1
    -1
      public/js/lib/bootstrap.min.js
  30. +2
    -1
      public/js/wn/form/control.js
  31. +90
    -0
      public/js/wn/form/dashboard.js
  32. +3
    -1
      public/js/wn/form/grid.js
  33. +59
    -3
      public/js/wn/form/layout.js
  34. +15
    -6
      public/js/wn/form/toolbar.js
  35. +3
    -2
      public/js/wn/misc/user.js
  36. +48
    -17
      public/js/wn/model/create_new.js
  37. +5
    -1
      public/js/wn/model/model.js
  38. +12
    -2
      public/js/wn/model/sync.js
  39. +11
    -4
      public/js/wn/ui/appframe.js
  40. +1
    -1
      public/js/wn/ui/field_group.js
  41. +13
    -3
      public/js/wn/ui/listing.js
  42. +1
    -1
      public/js/wn/views/communication.js
  43. +3
    -2
      public/js/wn/views/doclistview.js
  44. +14
    -11
      public/js/wn/views/moduleview.js
  45. +5
    -1
      webnotes/__init__.py
  46. +3
    -1
      webnotes/client.py
  47. +10
    -3
      webnotes/db.py
  48. +3
    -1
      webnotes/handler.py
  49. +0
    -1
      webnotes/model/bean.py
  50. +53
    -0
      webnotes/model/create_new.py
  51. +104
    -0
      webnotes/model/mapper.py
  52. +18
    -3
      webnotes/widgets/form/load.py
  53. +1
    -1
      webnotes/widgets/form/run_method.py
  54. +0
    -7
      webnotes/widgets/moduleview.py

+ 11
- 11
core/doctype/docfield/docfield.txt Visa fil

@@ -2,7 +2,7 @@
{ {
"creation": "2013-02-22 01:27:33", "creation": "2013-02-22 01:27:33",
"docstatus": 0, "docstatus": 0,
"modified": "2013-03-07 07:03:20",
"modified": "2013-07-03 10:03:56",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@@ -94,6 +94,16 @@
"search_index": 0, "search_index": 0,
"width": "50px" "width": "50px"
}, },
{
"doctype": "DocField",
"fieldname": "description",
"fieldtype": "Text",
"label": "Description",
"oldfieldname": "description",
"oldfieldtype": "Text",
"print_width": "300px",
"width": "300px"
},
{ {
"default": "0", "default": "0",
"doctype": "DocField", "doctype": "DocField",
@@ -241,16 +251,6 @@
"search_index": 0, "search_index": 0,
"width": "50px" "width": "50px"
}, },
{
"doctype": "DocField",
"fieldname": "description",
"fieldtype": "Text",
"label": "Description",
"oldfieldname": "description",
"oldfieldtype": "Text",
"print_width": "300px",
"width": "300px"
},
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "oldfieldname", "fieldname": "oldfieldname",


+ 7
- 0
core/doctype/doctype/doctype.js Visa fil

@@ -23,6 +23,13 @@
// ------------- // -------------
// Menu Display // Menu Display
// ------------- // -------------

$(cur_frm.wrapper).on("grid-row-render", function(e, grid_row) {
if(grid_row.doc && grid_row.doc.fieldtype=="Section Break") {
$(grid_row.row).css({"font-weight": "bold"});
}
})

cur_frm.cscript.allow_attach = function(doc, cdt, cdn) { cur_frm.cscript.allow_attach = function(doc, cdt, cdn) {
if(doc.allow_attach) { if(doc.allow_attach) {
unhide_field('max_attachments'); unhide_field('max_attachments');


+ 1
- 0
core/doctype/doctype_mapper/doctype_mapper.py Visa fil

@@ -306,3 +306,4 @@ class DocType:
if hasattr(conf, 'developer_mode') and conf.developer_mode: if hasattr(conf, 'developer_mode') and conf.developer_mode:
from webnotes.modules.export_file import export_to_files from webnotes.modules.export_file import export_to_files
export_to_files(record_list=[[self.doc.doctype, self.doc.name]]) export_to_files(record_list=[[self.doc.doctype, self.doc.name]])


+ 4
- 1
core/doctype/letter_head/letter_head.py Visa fil

@@ -30,7 +30,7 @@ class DocType:
self.doc = doc self.doc = doc
self.doclist = doclist self.doclist = doclist
def on_update(self):
def validate(self):
self.set_as_default() self.set_as_default()
# clear the cache so that the new letter head is uploaded # clear the cache so that the new letter head is uploaded
@@ -38,6 +38,9 @@ class DocType:
def set_as_default(self): def set_as_default(self):
from webnotes.utils import set_default from webnotes.utils import set_default
if not self.doc.is_default:
if not sql("""select count(*) from `tabLetter Head` where ifnull(is_default,0)=1"""):
self.doc.is_default = 1
if self.doc.is_default: if self.doc.is_default:
sql("update `tabLetter Head` set is_default=0 where name != %s", sql("update `tabLetter Head` set is_default=0 where name != %s",
self.doc.name) self.doc.name)


+ 8
- 20
public/build.json Visa fil

@@ -17,10 +17,6 @@
"lib/public/css/bootstrap-responsive.css", "lib/public/css/bootstrap-responsive.css",
"lib/public/css/font-awesome.css", "lib/public/css/font-awesome.css",
"lib/public/css/legacy/forms.css", "lib/public/css/legacy/forms.css",
"lib/public/css/legacy/fields.css",
"lib/public/css/legacy/dialog.css",
"lib/public/css/legacy/tabs.css",
"lib/public/css/legacy/sidebar.css",
"lib/public/css/ui/common.css", "lib/public/css/ui/common.css",
"lib/public/css/views/tree_grid.css", "lib/public/css/views/tree_grid.css",
] ]
@@ -39,9 +35,6 @@
"lib/public/js/lib/jquery/jquery.hotkeys.js", "lib/public/js/lib/jquery/jquery.hotkeys.js",
"lib/public/js/lib/center_image.js", "lib/public/js/lib/center_image.js",
"lib/public/js/lib/bootstrap.min.js", "lib/public/js/lib/bootstrap.min.js",
"lib/public/js/lib/tiny_mce_3.5.7/jquery.tinymce.js:concat",
"lib/public/js/lib/mousetrap.min.js",
"lib/public/js/wn/provide.js", "lib/public/js/wn/provide.js",
"lib/public/js/wn/class.js", "lib/public/js/wn/class.js",
@@ -56,9 +49,13 @@
"lib/public/js/wn/defaults.js", "lib/public/js/wn/defaults.js",


"lib/public/js/legacy/globals.js", "lib/public/js/legacy/globals.js",
"lib/public/js/legacy/utils/datatype.js",
"lib/public/js/legacy/utils/datetime.js",
"lib/public/js/legacy/utils/dom.js",
"lib/public/js/legacy/datatype.js",
"lib/public/js/legacy/datetime.js",
"lib/public/js/legacy/dom.js",
"lib/public/js/legacy/handler.js",
"lib/public/js/legacy/printElement.js",
"lib/public/js/legacy/loaders.js",

"lib/public/js/wn/ui/appframe.js", "lib/public/js/wn/ui/appframe.js",
"lib/public/js/wn/ui/field_group.js", "lib/public/js/wn/ui/field_group.js",
"lib/public/js/wn/ui/dialog.js", "lib/public/js/wn/ui/dialog.js",
@@ -79,11 +76,6 @@
"lib/public/js/wn/misc/datetime.js", "lib/public/js/wn/misc/datetime.js",
"lib/public/js/wn/misc/number_format.js", "lib/public/js/wn/misc/number_format.js",


"lib/public/js/legacy/utils/handler.js",
"lib/public/js/legacy/utils/printElement.js",
"lib/public/js/legacy/widgets/dialog.js",
"lib/public/js/legacy/webpage/loaders.js",

"lib/public/js/wn/upload.js", "lib/public/js/wn/upload.js",
"lib/public/js/wn/ui/filters.js", "lib/public/js/wn/ui/filters.js",
"lib/public/js/wn/ui/search.js", "lib/public/js/wn/ui/search.js",
@@ -106,11 +98,7 @@
"lib/public/js/wn/views/test_runner.js", "lib/public/js/wn/views/test_runner.js",
"lib/public/js/wn/form/formatters.js", "lib/public/js/wn/form/formatters.js",


"lib/public/js/legacy/webpage/page_header.js",
"lib/public/js/legacy/widgets/layout.js", "lib/public/js/legacy/widgets/layout.js",
"lib/public/js/legacy/widgets/export_query.js",
"lib/public/js/legacy/wn/page_layout.js",
"lib/public/js/legacy/wn/widgets/page_sidebar.js",
"lib/public/js/wn/ui/toolbar/selector_dialog.js", "lib/public/js/wn/ui/toolbar/selector_dialog.js",
"lib/public/js/wn/ui/toolbar/new.js", "lib/public/js/wn/ui/toolbar/new.js",
@@ -124,10 +112,10 @@
"lib/public/js/legacy/widgets/form/form.js", "lib/public/js/legacy/widgets/form/form.js",
"lib/public/js/legacy/widgets/form/print_format.js", "lib/public/js/legacy/widgets/form/print_format.js",
"lib/public/js/legacy/widgets/form/clientscriptAPI.js", "lib/public/js/legacy/widgets/form/clientscriptAPI.js",
"lib/public/js/legacy/wn/widgets/form/sidebar.js",


"lib/public/js/wn/form/toolbar.js", "lib/public/js/wn/form/toolbar.js",
"lib/public/js/wn/form/layout.js", "lib/public/js/wn/form/layout.js",
"lib/public/js/wn/form/dashboard.js",
"lib/public/js/wn/form/script_manager.js", "lib/public/js/wn/form/script_manager.js",
"lib/public/js/wn/form/control.js", "lib/public/js/wn/form/control.js",
"lib/public/js/wn/form/link_selector.js", "lib/public/js/wn/form/link_selector.js",


+ 120
- 33
public/css/bootstrap.css Visa fil

@@ -325,9 +325,13 @@ a:focus {
} }


img { img {
vertical-align: middle;
}

.img-responsive {
display: inline-block;
height: auto; height: auto;
max-width: 100%; max-width: 100%;
vertical-align: middle;
} }


.img-rounded { .img-rounded {
@@ -1482,6 +1486,11 @@ input[type="checkbox"]:focus {
outline-offset: -2px; outline-offset: -2px;
} }


input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
height: auto;
}

input:-moz-placeholder, input:-moz-placeholder,
textarea:-moz-placeholder { textarea:-moz-placeholder {
color: #999999; color: #999999;
@@ -1601,6 +1610,7 @@ input[type="color"].input-small {
border-radius: 3px; border-radius: 3px;
} }


.has-warning .help-block,
.has-warning .control-label { .has-warning .control-label {
color: #c09853; color: #c09853;
} }
@@ -1624,6 +1634,7 @@ input[type="color"].input-small {
border-color: #c09853; border-color: #c09853;
} }


.has-error .help-block,
.has-error .control-label { .has-error .control-label {
color: #b94a48; color: #b94a48;
} }
@@ -1647,6 +1658,7 @@ input[type="color"].input-small {
border-color: #b94a48; border-color: #b94a48;
} }


.has-success .help-block,
.has-success .control-label { .has-success .control-label {
color: #468847; color: #468847;
} }
@@ -2322,6 +2334,11 @@ input[type="button"].btn-block {
border-bottom-left-radius: 4px; border-bottom-left-radius: 4px;
} }


.list-group-item > .badge {
float: right;
margin-right: -15px;
}

.list-group-item-heading { .list-group-item-heading {
margin-top: 0; margin-top: 0;
margin-bottom: 5px; margin-bottom: 5px;
@@ -2361,16 +2378,6 @@ a.list-group-item.active .list-group-item-text {
color: #e1edf7; color: #e1edf7;
} }


.list-group-item > .badge,
.list-group-item > .glyphicon-chevron-right {
float: right;
margin-right: -15px;
}

.list-group-item > .glyphicon + .badge {
margin-right: 5px;
}

.panel { .panel {
padding: 15px; padding: 15px;
margin-bottom: 20px; margin-bottom: 20px;
@@ -3206,11 +3213,6 @@ button.close {
padding-left: 8px; padding-left: 8px;
} }


.btn-group > .btn-mini + .dropdown-toggle {
padding-right: 5px;
padding-left: 5px;
}

.btn-group > .btn-large + .dropdown-toggle { .btn-group > .btn-large + .dropdown-toggle {
padding-right: 12px; padding-right: 12px;
padding-left: 12px; padding-left: 12px;
@@ -3304,6 +3306,7 @@ button.close {


.pagination { .pagination {
display: inline-block; display: inline-block;
padding-left: 0;
margin: 20px 0; margin: 20px 0;
border-radius: 4px; border-radius: 4px;
} }
@@ -3395,6 +3398,7 @@ button.close {
} }


.pager { .pager {
padding-left: 0;
margin: 20px 0; margin: 20px 0;
text-align: center; text-align: center;
list-style: none; list-style: none;
@@ -3962,8 +3966,11 @@ button.close {
display: block; display: block;
} }


.thumbnail > img,
.img-thumbnail { .img-thumbnail {
display: inline-block; display: inline-block;
height: auto;
max-width: 100%;
} }


a.thumbnail:hover, a.thumbnail:hover,
@@ -3972,8 +3979,6 @@ a.thumbnail:focus {
} }


.thumbnail > img { .thumbnail > img {
display: block;
max-width: 100%;
margin-right: auto; margin-right: auto;
margin-left: auto; margin-left: auto;
} }
@@ -4015,7 +4020,7 @@ a.thumbnail:focus {
} }


.media-list { .media-list {
margin-left: 0;
padding-left: 0;
list-style: none; list-style: none;
} }


@@ -4108,10 +4113,6 @@ a.badge:focus {
top: -1px; top: -1px;
} }


.btn-mini .badge {
top: 0;
}

a.list-group-item.active > .badge, a.list-group-item.active > .badge,
.nav-pills > .active > a > .badge { .nav-pills > .active > a > .badge {
color: #428bca; color: #428bca;
@@ -4279,9 +4280,6 @@ a.list-group-item.active > .badge,
.accordion-heading .accordion-toggle { .accordion-heading .accordion-toggle {
display: block; display: block;
padding: 8px 15px; padding: 8px 15px;
}

.accordion-toggle {
cursor: pointer; cursor: pointer;
} }


@@ -4311,7 +4309,9 @@ a.list-group-item.active > .badge,


.carousel-inner > .item > img, .carousel-inner > .item > img,
.carousel-inner > .item > a > img { .carousel-inner > .item > a > img {
display: block;
display: inline-block;
height: auto;
max-width: 100%;
line-height: 1; line-height: 1;
} }


@@ -4418,24 +4418,26 @@ a.list-group-item.active > .badge,
z-index: 15; z-index: 15;
width: 100px; width: 100px;
padding-left: 0; padding-left: 0;
margin: 0 0 0 -50px;
margin-left: -50px;
text-align: center; text-align: center;
list-style: none; list-style: none;
} }


.carousel-indicators li { .carousel-indicators li {
display: inline-block; display: inline-block;
width: 8px;
height: 8px;
margin-right: 0;
margin-left: 0;
width: 10px;
height: 10px;
margin: 1px;
text-indent: -999px; text-indent: -999px;
cursor: pointer; cursor: pointer;
border: 1px solid #fff; border: 1px solid #fff;
border-radius: 5px;
border-radius: 10px;
} }


.carousel-indicators .active { .carousel-indicators .active {
width: 12px;
height: 12px;
margin: 0;
background-color: #fff; background-color: #fff;
} }


@@ -4574,14 +4576,41 @@ td.visible-sm {
display: none !important; display: none !important;
} }


tr.visible-md {
display: none !important;
}

th.visible-md,
td.visible-md {
display: none !important;
}

.visible-lg { .visible-lg {
display: none !important; display: none !important;
} }


tr.visible-lg {
display: none !important;
}

th.visible-lg,
td.visible-lg {
display: none !important;
}

.hidden-sm { .hidden-sm {
display: none !important; display: none !important;
} }


tr.hidden-sm {
display: none !important;
}

th.hidden-sm,
td.hidden-sm {
display: none !important;
}

.hidden-md { .hidden-md {
display: block !important; display: block !important;
} }
@@ -4612,6 +4641,13 @@ td.hidden-lg {
.visible-sm { .visible-sm {
display: none !important; display: none !important;
} }
tr.visible-sm {
display: none !important;
}
th.visible-sm,
td.visible-sm {
display: none !important;
}
.visible-md { .visible-md {
display: block !important; display: block !important;
} }
@@ -4625,6 +4661,13 @@ td.hidden-lg {
.visible-lg { .visible-lg {
display: none !important; display: none !important;
} }
tr.visible-lg {
display: none !important;
}
th.visible-lg,
td.visible-lg {
display: none !important;
}
.hidden-sm { .hidden-sm {
display: block !important; display: block !important;
} }
@@ -4638,6 +4681,13 @@ td.hidden-lg {
.hidden-md { .hidden-md {
display: none !important; display: none !important;
} }
tr.hidden-md {
display: none !important;
}
th.hidden-md,
td.hidden-md {
display: none !important;
}
.hidden-lg { .hidden-lg {
display: block !important; display: block !important;
} }
@@ -4654,9 +4704,23 @@ td.hidden-lg {
.visible-sm { .visible-sm {
display: none !important; display: none !important;
} }
tr.visible-sm {
display: none !important;
}
th.visible-sm,
td.visible-sm {
display: none !important;
}
.visible-md { .visible-md {
display: none !important; display: none !important;
} }
tr.visible-md {
display: none !important;
}
th.visible-md,
td.visible-md {
display: none !important;
}
.visible-lg { .visible-lg {
display: block !important; display: block !important;
} }
@@ -4690,12 +4754,28 @@ td.hidden-lg {
.hidden-lg { .hidden-lg {
display: none !important; display: none !important;
} }
tr.hidden-lg {
display: none !important;
}
th.hidden-lg,
td.hidden-lg {
display: none !important;
}
} }


.visible-print { .visible-print {
display: none !important; display: none !important;
} }


tr.visible-print {
display: none !important;
}

th.visible-print,
td.visible-print {
display: none !important;
}

@media print { @media print {
.visible-print { .visible-print {
display: block !important; display: block !important;
@@ -4710,4 +4790,11 @@ td.hidden-lg {
.hidden-print { .hidden-print {
display: none !important; display: none !important;
} }
tr.hidden-print {
display: none !important;
}
th.hidden-print,
td.hidden-print {
display: none !important;
}
} }

+ 0
- 75
public/css/legacy/dialog.css Visa fil

@@ -1,75 +0,0 @@
/***** Dialogs *******/

div.dialog_wrapper {
position: absolute;
width: 440px;
display: none;
z-index: 2;
background-color: #FFF;
box-shadow:1px 1px 8px #444;
-moz-box-shadow: 1px 1px 8px #444;
-webkit-box-shadow: 1px 1px 8px #444;
border-radius: 5px;
overflow: hidden;
}

div.dialog_head {
height: 22px;
padding: 4px;
background-color: #222;
color: #FFF;
}

div.dialog_body {
padding: 8px 8px 16px;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}

div#freeze {
position: fixed;
display: none;
top: 0px;
left: 0px;
bottom: 0px;
right: 0px;
background-color: #aaa;
opacity: 0.6;
z-index: 1;
text-align: center;
}

div.dialog_message {
display: none;
position: absolute;
width: 250px;
font-size: 12px;
z-index: 91;
background-color:#FFF;
padding: 12px;
border: 1px solid #444;
}

div.dialog_row {
padding: 8px 8px 0px 8px;
}

div.dialog_row table {
width: 100%;
}

div.dialog_row table td {
}

div.dialog_row input[type="text"], div.dialog_row input[type="password"], div.dialog_row textarea, div.dialog_row select {
width: 80%;
font-size: 14px;
}

div.dialog_row table td textarea {
width: 80%;
height: 200px;
font-size: 12px;
}

+ 0
- 7
public/css/legacy/fields.css Visa fil

@@ -5,13 +5,6 @@
/* Documents */ /* Documents */




.help ol {
padding-left: 19px;
}

.field_description_top {
margin-bottom: 3px;
}




.link-field .btn { .link-field .btn {


+ 0
- 32
public/css/legacy/sidebar.css Visa fil

@@ -1,32 +0,0 @@
div.psidebar {
}

div.psidebar div.head {
font-size: 14px;
font-weight: bold;
color: #555;
margin-bottom: 12px;
}

div.section {
margin-bottom: 15px;
overflow: hidden;
}

div.section div.section-head {
padding: 5px 0px;
font-size: 109%;
font-weight: bold;
}

div.section div.section-body {
}

div.section div.section-item {
margin-bottom: 7px;
}

div.section div.section-item, div.section .section-link {
color: #666;
}

+ 80
- 5
public/css/ui/common.css Visa fil

@@ -22,6 +22,21 @@ a {
padding-bottom: 10px; padding-bottom: 10px;
} }


/* freeze */

div#freeze {
position: fixed;
display: none;
top: 0px;
left: 0px;
bottom: 0px;
right: 0px;
background-color: #aaa;
opacity: 0.6;
z-index: 1;
text-align: center;
}

/* listing */ /* listing */


.list-row { .list-row {
@@ -47,21 +62,44 @@ a {


/* module */ /* module */


.module-top .alert {
.alert-badge {
padding-right: 15px; padding-right: 15px;
margin-bottom: 10px;
} }


.module-top a, .module-top a:hover {
.alert-badge a, .alert-badge a:hover {
color: black; color: black;
font-size: 120%; font-size: 120%;
font-weight: bold; font-weight: bold;
} }


.module-top .badge {
.alert-badge .badge {
margin-top: 3px; margin-top: 3px;
} }


.form-headline {
margin-bottom: 10px;
font-size: 130%;
}

.form-dashboard {
display: none;
border-bottom: 1px solid #ddd;
}

.help ol {
padding-left: 19px;
}

.field_description_top {
margin-bottom: 3px;
}

.link-field .btn {
padding-left: 6px;
padding-right: 6px;
}
/* module */

.module-item-progress { .module-item-progress {
margin-bottom: 10px; margin-bottom: 10px;
height: 17px; height: 17px;
@@ -160,6 +198,12 @@ a {
font-size: 24px; font-size: 24px;
} }


.appframe .sub-title-area {
margin-top: -25px;
margin-left: 75px;
font-size: 120%;
}

.appframe .title-icon:active { .appframe .title-icon:active {
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.3); -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.3);
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.3); box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.3);
@@ -384,4 +428,35 @@ textarea[data-fieldtype="Small Text"] {
.hidden-sm-inline { .hidden-sm-inline {
display: inline; display: inline;
} }
}
}

/* buttons */
.btn-default {
color: #ffffff;
background-color: #a7a9aa;
border-color: #a7a9aa;
}

.btn-default:hover,
.btn-default:focus,
.btn-default:active,
.btn-default.active {
background-color: #9a9c9d;
border-color: #8d9091;
}

.btn-default.disabled:hover,
.btn-default[disabled]:hover,
fieldset[disabled] .btn-default:hover,
.btn-default.disabled:focus,
.btn-default[disabled]:focus,
fieldset[disabled] .btn-default:focus,
.btn-default.disabled:active,
.btn-default[disabled]:active,
fieldset[disabled] .btn-default:active,
.btn-default.disabled.active,
.btn-default[disabled].active,
fieldset[disabled] .btn-default.active {
background-color: #a7a9aa;
border-color: #a7a9aa;
}

+ 0
- 1
public/html/server.py Visa fil

@@ -41,7 +41,6 @@ import webnotes.auth


def init(): def init():
webnotes.handler.get_cgi_fields() webnotes.handler.get_cgi_fields()
# init request # init request
try: try:
webnotes.http_request = webnotes.auth.HTTPRequest() webnotes.http_request = webnotes.auth.HTTPRequest()


public/js/legacy/utils/datatype.js → public/js/legacy/datatype.js Visa fil


public/js/legacy/utils/datetime.js → public/js/legacy/datetime.js Visa fil


public/js/legacy/utils/dom.js → public/js/legacy/dom.js Visa fil


public/js/legacy/utils/handler.js → public/js/legacy/handler.js Visa fil

@@ -37,7 +37,7 @@ function $c_obj(doclist, method, arg, callback, no_spinner, freeze_msg, btn) {
args = { args = {
cmd:'runserverobj', cmd:'runserverobj',
arg: arg,
args: arg,
method: method method: method
}; };

public/js/legacy/webpage/loaders.js → public/js/legacy/loaders.js Visa fil


public/js/legacy/utils/printElement.js → public/js/legacy/printElement.js Visa fil


+ 0
- 94
public/js/legacy/webpage/page_header.js Visa fil

@@ -1,94 +0,0 @@
// Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
//
// MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

/* standard page header

+ wrapper
+ [table]
+ [r1c1]
+ main_head
+ sub_head
+ [r1c2]
+ close_btn
+ toolbar_area
+ tag_area
+ seperator
*/

var def_ph_style = {
wrapper: {marginBottom:'16px', backgroundColor:'#EEE'}
,main_heading: { }
,sub_heading: { marginBottom:'8px', color:'#555', display:'none' }
,separator: { borderTop:'1px solid #ddd' } // show this when there is no toolbar
,toolbar_area: { padding:'3px 0px', display:'none',borderBottom:'1px solid #ddd'}
}

function PageHeader(parent, main_text, sub_text) {

this.wrapper = $a(parent,'div','page_header');
this.close_btn = $a(this.wrapper, 'a', 'close', {}, '×');
this.close_btn.onclick = function() { window.history.back(); };
this.main_head = $a(this.wrapper, 'h1', '', def_ph_style.main_heading);
this.sub_head = $a(this.wrapper, 'h4', '', def_ph_style.sub_heading);

this.separator = $a(this.wrapper, 'div', '', def_ph_style.separator);
this.toolbar_area = $a(this.wrapper, 'div', '', def_ph_style.toolbar_area);
this.padding_area = $a(this.wrapper, 'div', '', {padding:'3px'});

if(main_text) this.main_head.innerHTML = main_text;
if(sub_text) this.sub_head.innerHTML = sub_text;
this.buttons = {};
this.buttons2 = {};
}

PageHeader.prototype.add_button = function(label, fn, bold, icon, green) {

var tb = this.toolbar_area;
if(this.buttons[label]) return;

iconhtml = icon ? ('<i class="'+icon+'"></i> ') : '';

var $button = $('<button class="btn">'+ iconhtml + label +'</button>')
.click(fn)
.appendTo(tb);
if(green) {
$button.addClass('btn-info');
$button.find('i').addClass('icon-white');
}
if(bold) $button.css('font-weight', 'bold');
this.buttons[label] = $button.get(0);
$ds(this.toolbar_area);
return this.buttons[label];
}

PageHeader.prototype.clear_toolbar = function() {
this.toolbar_area.innerHTML = '';
this.buttons = {};
}

PageHeader.prototype.make_buttonset = function() {
$(this.toolbar_area).buttonset();
}

+ 0
- 231
public/js/legacy/webpage/search.js Visa fil

@@ -1,231 +0,0 @@
// Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
//
// MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

search_fields = {};

// Search Selector 2.0
// -------------------

function setlinkvalue(name) {
//selector.input.set(name);// in local - this will be set onchange
selector.input.set_input(name); // on screen
selector.hide();
}

// Link Selector
// -------------

function makeselector() {
var d = new Dialog(540,440, 'Search');

d.make_body([
['HTML', 'Help'],
['Data', 'Beginning With', 'Tip: You can use wildcard "%"'],
['Select', 'Search By'],
['Button', 'Search'],
['HTML', 'Result']
]);

// search with
var inp = d.widgets['Beginning With'];
var field_sel = d.widgets['Search By'];
var btn = d.widgets['Search'];

// result
d.sel_type = '';
d.values_len = 0;
d.set = function(input, type, label) {
d.sel_type = type;
d.input = input;
if(d.style!='Link') {
d.rows['Result'].innerHTML ='';
d.values_len = 0;
}
d.style = 'Link';
d.set_query_description()

if(!d.sel_type)d.sel_type = 'Value';
d.set_title("Select");
d.set_query_description('Select a "'+ d.sel_type +'" for field "'+label+'"');
}
d.set_search = function(dt) {
if(d.style!='Search') {
d.rows['Result'].innerHTML ='';
d.values_len = 0;
}
d.style = 'Search';
if(d.input) { d.input = null; sel_type = null; }
d.sel_type = dt;
d.set_title('Quick Search for ' + dt);
}

$(inp).keydown(function(e) {
if(e.which==13) {
if(!btn.disabled)btn.onclick();
}
})

d.set_query_description = function(txt) {
txt = d.input && d.input.query_description || txt;
if(txt) {
d.rows['Help'].innerHTML ='<div class="alert" style="margin-top:0px">' + txt + '</div>';
} else {
d.rows['Help'].innerHTML =''
}
}
d.onshow = function() {
if(d.set_doctype!=d.sel_type) {
d.rows['Result'].innerHTML ='';
d.values_len = 0;
}

inp.value = '';
if(d.input && d.get_value) {
inp.value = d.get_value();
}
try{inp.focus();} catch(e){}

// temp function to strip labels from search fields
var get_sf_list = function(dt) {
var l = []; var lf = search_fields[dt];
for(var i=0; i<lf.length; i++) l.push(lf[i][1]);
return l;
}

// set fields
$ds(d.rows['Search By']);

if(search_fields[d.sel_type]) {
empty_select(field_sel);
add_sel_options(field_sel, get_sf_list(d.sel_type), 'ID');
} else {
// set default select by
empty_select(field_sel);
add_sel_options(field_sel, ['ID'], 'ID');

$c('webnotes.widgets.search.getsearchfields', {'doctype':d.sel_type}, function(r,rt) {
search_fields[d.sel_type] = r.searchfields;
empty_select(field_sel);
add_sel_options(field_sel, get_sf_list(d.sel_type));
field_sel.selectedIndex = 0;
} );
}
}
d.onhide = function() {
//if(d.input && d.input.txt) // link, call onchange
// d.input.txt.set_input_value()
}

btn.onclick = function() {
if(this.disabled) return;

this.args.is_ajax = true;
d.set_doctype = d.sel_type;
var q = '';
args = {};

if(d.input && d.input.get_query) {
var doc = {};
args.is_simple = 1;
if(cur_frm) doc = locals[cur_frm.doctype][cur_frm.docname];
var q = d.input.get_query(doc, d.input.doctype, d.input.docname);
if(!q) { return ''; }
if (typeof(q)==="string") {
args.query = q;
} else if($.isPlainObject(q)) {
if(q.filters) {
$.each(q.filters, function(key, value) {
q.filters[key] = value===undefined ? null : value;
});
}
$.extend(args, q);
}
}

// for field type, return field name
var get_sf_fieldname = function(v) {
var lf = search_fields[d.sel_type];

// still loading options
if(!lf)
return 'name'

for(var i=0; i<lf.length; i++) if(lf[i][1]==v) return lf[i][0];
}

// build args
$.extend(args, {
'txt':strip(inp.value),
'doctype':d.sel_type,
'searchfield':get_sf_fieldname(sel_val(field_sel))
});

// run the query
wn.call({
method: "webnotes.widgets.search.search_widget",
args: args,
callback: function(r) {
if(r.coltypes)r.coltypes[0]='Link'; // first column must always be selectable even if it is not a link
d.values_len = r.values.length;
d.set_result(r);
},
btn: btn
});
}

d.set_result = function(r) {
d.rows['Result'].innerHTML = '';
var c = $a(d.rows['Result'],'div','comment',{paddingBottom:'4px',marginBottom:'4px',borderBottom:'1px solid #CCC', marginLeft:'4px'});
if(r.values.length==50)
c.innerHTML = 'Showing max 50 results. Use filters to narrow down your search';
else
c.innerHTML = 'Showing '+r.values.length+' resuts.';

var w = $a(d.rows['Result'],'div','',{height:'240px',overflow:'auto',margin:'4px'});
for(var i=0; i<r.values.length; i++) {
var div = $a(w,'div','',
{marginBottom:'4px',paddingBottom:'4px',borderBottom:'1px dashed #CCC'});

// link
var l = $a($a(div,'div'),'span','link_type');
l.innerHTML = r.values[i][0];
l.link_name = r.values[i][0];
l.dt = r.coloptions && r.coloptions[0];

if(d.input)
l.onclick = function() { setlinkvalue(this.link_name); }
else
l.onclick = function() { loaddoc(this.dt, this.link_name); d.hide(); }

// support
var cl = []
for(var j=1; j<r.values[i].length; j++) cl.push(r.values[i][j]);
var c = $a(div,'div','comment',{marginTop:'2px'}); c.innerHTML = cl.join(', ');
}

}

selector = d;
}

+ 0
- 145
public/js/legacy/widgets/dialog.js Visa fil

@@ -1,145 +0,0 @@
// Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
//
// MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

//
// Dialog - old style dialog - deprecated
//


var Dialog = wn.ui.Dialog.extend({
init: function(w, h, title, content) {
this._super({
width: w,
title: title
});
if(content)this.make_body(content);

this.onshow = '';
this.oncancel = '';
this.no_cancel_flag = 0; // allow to cancel
this.display = false;
this.first_button = false;
},
make_body: function(content) {
this.rows = {}; this.widgets = {};
for(var i in content) this.make_row(content[i]);
},
clear_inputs: function(d) {
for(var wid in this.widgets) {
var w = this.widgets[wid];

var tn = w.tagName ? w.tagName.toLowerCase() : '';
if(tn=='input' || tn=='textarea') {
w.value = '';
} else if(tn=='select') {
sel_val(w.options[0].value);
} else if(w.txt) {
w.txt.value = '';
} else if(w.input) {
w.input.value = '';
}
}
},
make_row: function(d) {
var me = this;

this.rows[d[1]] = $a(this.body, 'div', 'dialog_row');
var row = this.rows[d[1]];

if(d[0]!='HTML') {
var t = make_table(row,1,2,'100%',['30%','70%']);
row.tab = t;
var c1 = $td(t,0,0);
var c2 = $td(t,0,1);
if(d[0]!='Check' && d[0]!='Button')
$(c1).text(d[1]);
}

if(d[0]=='HTML') {
if(d[2])row.innerHTML = d[2];
this.widgets[d[1]]=row;
}
else if(d[0]=='Check') {
var i = $a_input(c2, 'checkbox','',{width:'20px'});
c1.innerHTML = d[1];
this.widgets[d[1]] = i;
}
else if(d[0]=='Data') {
c1.innerHTML = d[1];
c2.style.overflow = 'auto';
this.widgets[d[1]] = $a_input(c2, 'text');
if(d[2])$a(c2, 'div', 'field_description').innerHTML = d[2];
}
else if(d[0]=='Link') {
c1.innerHTML = d[1];
var f = make_field({fieldtype:'Link', 'label':d[1], 'options':d[2]}, '', c2, this, 0, 1);
f.not_in_form = 1;
f.dialog = this;
f.refresh();
this.widgets[d[1]] = f.input;
}
else if(d[0]=='Date') {
c1.innerHTML = d[1];
var f = make_field({fieldtype:'Date', 'label':d[1], 'options':d[2]}, '', c2, this, 0, 1);
f.not_in_form = 1;
f.refresh();
f.dialog = this;
this.widgets[d[1]] = f.input;
}
else if(d[0]=='Password') {
c1.innerHTML = d[1];
c2.style.overflow = 'auto';
this.widgets[d[1]] = $a_input(c2, 'password');
if(d[3])$a(c2, 'div', 'field_description').innerHTML = d[3];

}
else if(d[0]=='Select') {
c1.innerHTML = d[1];
this.widgets[d[1]] = $a(c2, 'select', '', {width:'160px'})
if(d[2])$a(c2, 'div', 'field_description').innerHTML = d[2];
if(d[3])add_sel_options(this.widgets[d[1]], d[3], d[3][0]);
}
else if(d[0]=='Text') {
c1.innerHTML = d[1];
c2.style.overflow = 'auto';
this.widgets[d[1]] = $a(c2, 'textarea');
if(d[2])$a(c2, 'div', 'field_description').innerHTML = d[2];
}
else if(d[0]=='Button') {
c2.style.height = '32px';
var b = $btn(c2, d[1], function(btn) {
if(btn._onclick) btn._onclick(me) }, null, null, 1);
b.dialog = me;
if(!this.first_button) {
$(b).addClass('btn-info');
this.first_button = true;
}
if(d[2]) {
b._onclick = d[2];
}
this.widgets[d[1]] = b;
}
}
});



+ 0
- 62
public/js/legacy/widgets/export_query.js Visa fil

@@ -1,62 +0,0 @@
// Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
//
// MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

var export_dialog;
function export_query(query, callback) {

if(!export_dialog) {
var d = new Dialog(400, 300, "Export...");
d.make_body([
['Data', 'Max rows', 'Blank to export all rows'],
['Button', 'Go'],
]);
d.widgets['Go'].onclick = function() {
export_dialog.hide();
n = export_dialog.widgets['Max rows'].value;
if(cint(n))
export_dialog.query += ' LIMIT 0,' + cint(n);
callback(export_dialog.query);
}
d.onshow = function() {
this.widgets['Max rows'].value = '500';
}
export_dialog = d;
}
export_dialog.query = query;
export_dialog.show();
}

function export_csv(q, report_name, sc_id, is_simple, filter_values, colnames) {
var args = {}
args.cmd = 'webnotes.widgets.query_builder.runquery_csv';
if(is_simple)
args.simple_query = q;
else
args.query = q;

args.sc_id = sc_id ? sc_id : '';
args.filter_values = filter_values ? filter_values: '';
if(colnames)
args.colnames = colnames.join(',');
args.report_name = report_name ? report_name : '';
open_url_post(wn.request.url, args);
}

+ 2
- 2
public/js/legacy/widgets/form/clientscriptAPI.js Visa fil

@@ -165,7 +165,7 @@ _f.Frm.prototype.get_doclist = function() {
} }


_f.Frm.prototype.field_map = function(fnames, fn) { _f.Frm.prototype.field_map = function(fnames, fn) {
if(typeof fnames=='string') {
if(typeof fnames==='string') {
if(fnames == '*') { if(fnames == '*') {
fnames = keys(this.fields_dict); fnames = keys(this.fields_dict);
} else { } else {
@@ -244,7 +244,7 @@ _f.Frm.prototype.set_value = function(field, value) {
_f.Frm.prototype.call = function(opts) { _f.Frm.prototype.call = function(opts) {
var me = this; var me = this;
if(!opts.doc) { if(!opts.doc) {
if(opts.method.indexOf(".")==-1)
if(opts.method.indexOf(".")===-1)
opts.method = wn.model.get_server_module_name(me.doctype) + "." + opts.method; opts.method = wn.model.get_server_module_name(me.doctype) + "." + opts.method;
opts.original_callback = opts.callback; opts.original_callback = opts.callback;
opts.callback = function(r) { opts.callback = function(r) {


+ 6
- 20
public/js/legacy/widgets/form/form.js Visa fil

@@ -151,8 +151,8 @@ _f.Frm.prototype.watch_model_updates = function() {
if(doc.name===me.docname) { if(doc.name===me.docname) {
me.fields_dict[fieldname] me.fields_dict[fieldname]
&& me.fields_dict[fieldname].refresh(fieldname); && me.fields_dict[fieldname].refresh(fieldname);
me.script_manager.trigger(fieldname, doc.doctype, doc.name);
me.refresh_dependency(); me.refresh_dependency();
me.script_manager.trigger(fieldname, doc.doctype, doc.name);
} }
}) })
@@ -190,10 +190,6 @@ _f.Frm.prototype.setup_std_layout = function() {
this.body_header = $a(this.main, 'div'); this.body_header = $a(this.main, 'div');
this.body = $a(this.main, 'div'); this.body = $a(this.main, 'div');


if(this.heading) {
this.page_head = new PageHeader(this.head, this);
}

// only tray // only tray
this.meta.section_style='Simple'; // always simple! this.meta.section_style='Simple'; // always simple!
@@ -203,6 +199,10 @@ _f.Frm.prototype.setup_std_layout = function() {
doctype: this.doctype, doctype: this.doctype,
frm: this, frm: this,
}); });

this.dashboard = new wn.ui.form.Dashboard({
frm: this,
});
// state // state
this.states = new wn.ui.form.States({ this.states = new wn.ui.form.States({
@@ -339,16 +339,6 @@ _f.Frm.prototype.refresh_print_layout = function() {
_p.build(this.$print_view_select.val(), print_callback, false, true, true); _p.build(this.$print_view_select.val(), print_callback, false, true, true);
} }



_f.Frm.prototype.show_the_frm = function() {
// show the dialog
if(this.meta.in_dialog && !this.parent.dialog.display) {
if(!this.meta.istable)
this.parent.table_form = false;
this.parent.dialog.show();
}
}

_f.Frm.prototype.set_print_heading = function(txt) { _f.Frm.prototype.set_print_heading = function(txt) {
this.pformat[cur_frm.docname] = txt; this.pformat[cur_frm.docname] = txt;
} }
@@ -546,7 +536,6 @@ _f.Frm.prototype.refresh_dependency = function() {
if(!has_dep)return; if(!has_dep)return;



// show / hide based on values // show / hide based on values
for(var i=me.fields.length-1;i>=0;i--) { for(var i=me.fields.length-1;i>=0;i--) {
var f = me.fields[i]; var f = me.fields[i];
@@ -580,9 +569,6 @@ _f.Frm.prototype.refresh_dependency = function() {
} }
} }


// setnewdoc is called when a record is loaded for the first time
// ======================================================================================

_f.Frm.prototype.setnewdoc = function(docname) { _f.Frm.prototype.setnewdoc = function(docname) {
// moved this call to refresh function // moved this call to refresh function
// this.check_doctype_conflict(docname); // this.check_doctype_conflict(docname);
@@ -602,7 +588,7 @@ _f.Frm.prototype.setnewdoc = function(docname) {
this.script_manager.trigger("onload"); this.script_manager.trigger("onload");
this.last_view_is_edit[docname] = 1; this.last_view_is_edit[docname] = 1;
if(cint(this.meta.read_only_onload)) this.last_view_is_edit[docname] = 0;
//if(cint(this.meta.read_only_onload)) this.last_view_is_edit[docname] = 0;
this.opendocs[docname] = true; this.opendocs[docname] = true;
} }


+ 36
- 49
public/js/legacy/widgets/form/print_format.js Visa fil

@@ -68,59 +68,46 @@ $.extend(_p, {
}, },
make_dialog: function() { make_dialog: function() {
// Prepare Dialog Box Layout
var d = new Dialog(
360, // w
140, // h
'Print Formats', // title
[ // content
['HTML', 'Select'],
['Check', 'No Letterhead'],
['HTML', 'Buttons']
]);
//d.widgets['No Letterhead'].checked = 1;
// Prepare Dialog Box Layout
var dialog = new wn.ui.Dialog({
title: "Print Formats",
fields: [
{fieldtype:"Select", label:"Print Format", fieldname:"print_format", reqd:1},
{fieldtype:"Check", label:"No Letter Head", fieldname:"no_letterhead"},
{fieldtype:"HTML", options: '<p style="text-align: right;">\
<button class="btn btn-primary btn-print">Print</button>\
<button class="btn btn-default btn-preview">Preview</button>\
</p>'},
]
})
// Print Button
$(d.widgets.Buttons).css({"height": "60px"})
$btn(d.widgets.Buttons, 'Print', function() {
_p.build(
sel_val(cur_frm.print_sel), // fmtname
_p.go, // onload
d.widgets['No Letterhead'].checked // no_letterhead
);
},
{
cssFloat: 'right',
marginBottom: '16px',
marginLeft: '7px',
}, 'green');
// Print Preview
$btn(d.widgets.Buttons, 'Preview', function() {
_p.build(
sel_val(cur_frm.print_sel), // fmtname
_p.preview, // onload
d.widgets['No Letterhead'].checked // no_letterhead
);
},
{
cssFloat: 'right',
marginBottom: '16px'
}, '');
dialog.$wrapper.find(".btn-print").click(function() {
var args = dialog.get_values();
_p.build(
args.print_format, // fmtname
_p.go, // onload
args.no_letterhead // no_letterhead
);
});

dialog.$wrapper.find(".btn-preview").click(function() {
var args = dialog.get_values();
_p.build(
args.print_format, // fmtname
_p.preview, // onload
args.no_letterhead // no_letterhead
);
});
// Delete previous print format select list and Reload print format list from current form
d.onshow = function() {
var c = _p.dialog.widgets['Select'];
if(c.cur_sel && c.cur_sel.parentNode == c) {
c.removeChild(c.cur_sel);
}
c.appendChild(cur_frm.print_sel);
c.cur_sel = cur_frm.print_sel;
dialog.onshow = function() {
var $print = dialog.fields_dict.print_format.$input;
$print.add_options(cur_frm.print_formats);
if(cur_frm.$print_view_select && cur_frm.$print_view_select.val()) if(cur_frm.$print_view_select && cur_frm.$print_view_select.val())
c.cur_sel.value= cur_frm.$print_view_select.val();
$print.val(cur_frm.$print_view_select.val());
} }
_p.dialog = d;
_p.dialog = dialog;
}, },
// Define formats dict // Define formats dict


+ 0
- 285
public/js/legacy/widgets/tags.js Visa fil

@@ -1,285 +0,0 @@
// Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
//
// MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

// =================================================
//
// Tag Globals
//
_tags = {
dialog: null,
color_map: {},
all_tags: [],
colors: {'Default':'#add8e6'}
//color_list: ['Default'] // for sequence
}

//
// Tag List
//
TagList = function(parent, start_list, dt, dn, static, onclick) {
this.start_list = start_list ? start_list : [];
this.tag_list = [];
this.dt = dt;
this.onclick = onclick;
this.dn = dn;
this.static;
this.parent = parent;
this.make_body();
}

TagList.prototype.make = function(parent) {
for(var i=0; i<this.start_list.length; i++) {
if(this.start_list[i])
new SingleTag({
parent: this.body,
label: this.start_list[i],
dt: this.dt,
dn: this.dn,
fieldname: '_user_tags',
static: this.static,
taglist: this,
onclick: this.onclick
});
}
}

TagList.prototype.make_body = function() {
var div = $a(this.parent, 'span', '', {margin:'3px 0px', padding:'3px 0px'});
this.body = $a(div, 'span', '', {marginRight:'4px'});
this.add_tag_area = $a(div, 'span');
this.make_add_tag();
this.make();
}

// render a new tag
TagList.prototype.add_tag = function(label, static, fieldname, color) {
if(!label) return;
if(in_list(this.tag_list, label)) return; // no double tags
var tag = new SingleTag({
parent: this.body,
label: label,
dt: this.dt,
dn: this.dn,
fieldname: fieldname,
static: static,
taglist: this,
color: color,
onclick: this.onclick
});
}

// add -tag area
TagList.prototype.make_add_tag = function() {
var me = this;
this.add_tag_span = $a(this.add_tag_area, 'span', '',
{color:'#888', textDecoration:'underline', cursor:'pointer',marginLeft:'4px',fontSize:'11px'});
this.add_tag_span.innerHTML = 'Add tag';
this.add_tag_span.onclick = function() { me.new_tag(); }
}

// new tag dialog
TagList.prototype.make_tag_dialog = function() {
var me = this;
var d = new wn.ui.Dialog({
title: 'Add a tag',
width: 400,
fields: [
{fieldtype:'Link', fieldname:'tag', label:'Tag', options:'Tag',
reqd:1, description:'Max chars (20)', no_buttons:1},
{fieldtype:'Button', fieldname: 'add', label:'Add'}
]
})
$(d.fields_dict.tag.input).attr('maxlength', 20);
d.fields_dict.add.input.onclick = function() { me.save_tag(d); }

return d;
}


// check if tag text is okay
TagList.prototype.is_text_okay = function(val) {
if(!val) {
msgprint(wn._("Please type something"));
return;
}
if(!validate_spl_chars(val)) {
msgprint(wn._("Special charaters, spaces, commas etc not allowed in tags"));
return;
}
return 1
}

// add to local
TagList.prototype.add_to_locals = function(tag) {
if(locals[this.dt] && locals[this.dt][this.dn]) {
var doc = locals[this.dt][this.dn];
if(!doc._user_tags) {
doc._user_tags = ''
}
var tl = doc._user_tags.split(',')
tl.push(tag)
doc._user_tags = tl.join(',');
}
}

// remove from local
TagList.prototype.remove_from_locals = function(tag) {
if(locals[this.dt] && locals[this.dt][this.dn]) {
var doc = locals[this.dt][this.dn];
var tl = doc._user_tags.split(',');
var new_tl = [];
for(var i=0; i<tl.length; i++) {
if(tl[i]!=tag) new_tl.push(tl[i]);
}
doc._user_tags = new_tl.join(',');
}
}

// save the tag
TagList.prototype.save_tag = function(d) {
var val = d.get_values();
if(val) val = val.tag;

var me = this;

if(!this.is_text_okay(val)) return;
var callback = function(r,rt) {
var d = me.dialog;
// hide the dialog
d.fields_dict.add.input.done_working();
d.fields_dict.tag.input.set_input('');
d.hide();
// add in locals
me.add_to_locals(val)

if(!r.message) return;
me.add_tag(r.message, 0, '_user_tags');
}
me.dialog.fields_dict.add.input.set_working();
$c('webnotes.widgets.tags.add_tag',{'dt': me.dt, 'dn': me.dn, 'tag':val, 'color':'na'}, callback);
}

// create a new tag
TagList.prototype.new_tag = function() {
var me = this;
if(!this.dialog) {
this.dialog = this.make_tag_dialog();
}
this.dialog.show();
}

// refresh tags
TagList.prototype.refresh_tags = function() {
}

//
// SingleTag
// parameters {parent, label, dt, dn, fieldname, static, taglist, color}
//
function SingleTag(opts) {
$.extend(this, opts);

if(!this.color) this.color = '#add8e6';
if(this.taglist && !in_list(this.taglist.tag_list, this.label))
this.taglist.tag_list.push(this.label);
this.make_body(this.parent);
}

// make body
SingleTag.prototype.make_body = function(parent) {
var me = this;
// tag area
this.body = $a(parent,'span','',{padding:'2px 4px', backgroundColor: this.color,
color:'#226', marginRight:'4px'});
$br(this.body,'3px');
if(this.onclick) $y(this.body, {cursor:'pointer'});
// hover
$(this.body).hover(function() {
$(this).css('opacity', 0.6);
} ,function() {
$(this).css('opacity', 1);
});

// label
this.make_label();
// remove btn
if(!this.static) this.make_remove_btn();
// add to all tags
_tags.all_tags.push(this);
}

// remove btn
SingleTag.prototype.make_remove_btn = function() {
var me = this;
var span = $a(this.body,'span');
span.innerHTML += ' |';
var span = $a(this.body,'span','',{cursor:'pointer'});
span.innerHTML = ' x'
span.onclick = function() { me.remove(me); }
}

// label
SingleTag.prototype.make_label = function() {
var me = this;
this.label_span = $a(this.body,'span', 'social', null, this.label);
this.label_span.onclick = function() { if(me.onclick) me.onclick(me); }
}

// remove
SingleTag.prototype.remove_tag_body = function() {
// clear tag
$dh(this.body);

// remove from tag_list
var nl=[];
for(var i in this.tag_list)
if(this.tag_list[i]!=this.label)
nl.push(this.tag_list[i]);
if(this.taglist)
this.taglist.tag_list = nl;
}

// remove
SingleTag.prototype.remove = function() {
var me = this;
var callback = function(r,rt) {
me.remove_tag_body()
me.taglist.remove_from_locals(me.label);
}
$c('webnotes.widgets.tags.remove_tag', {'dt':me.dt, 'dn':me.dn, 'tag':me.label}, callback)
$bg(me.body,'#DDD');
}

+ 0
- 210
public/js/legacy/widgets/tree.js Visa fil

@@ -1,210 +0,0 @@
// Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
//
// MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

// Tree
// ---------------------------------

function Tree(parent, width, do_animate) {
this.width = width;
this.nodes = {};
this.allnodes = {};
this.cur_node;
this.is_root = 1;
this.do_animate = do_animate;
var me = this;
this.exp_img = 'lib/images/icons/plus.gif';
this.col_img = 'lib/images/icons/minus.gif';
this.body = $a(parent, 'div');
if(width)$w(this.body, width);

this.addNode = function(parent, id, imagesrc, onclick, onexpand, opts, label) {
var t = new TreeNode(me, parent, id, imagesrc, onclick, onexpand, opts, label);
if(!parent) {
me.nodes[id]=t; // add to roots
} else {
parent.nodes[id]=t; // add to the node
}
me.allnodes[id] = t;

// note: this will only be for groups
if(onexpand)
t.create_expimage();
t.expanded_once = 0;

return t;
}
var me = this;
this.collapseall = function() {
for(n in me.allnodes) {
me.allnodes[n].collapse();
}
}
}

function TreeNode(tree, parent, id, imagesrc, onclick, onexpand, opts, label) {
var me = this;
if(!parent) parent = tree;
this.parent = parent;
this.nodes = {};
this.onclick = onclick;
this.onexpand = onexpand;
this.text = label ? label : id;
this.tree = tree;

if(opts)
this.opts = opts;
else
this.opts = {
show_exp_img:1
,show_icon:1
,label_style:{padding:'2px', cursor: 'pointer', fontSize:'11px'}
,onselect_style:{fontWeight: 'bold'}
,ondeselect_style:{fontWeight: 'normal'}
} // only useful for 1st node in the tree

var tc = 1;
if(this.opts.show_exp_img) tc+=1;

if(!this.parent.tab) {
this.parent.tab = make_table(this.parent.body, 2, tc, '100%');
$y(this.parent.tab,{tableLayout:'fixed',borderCollapse: 'collapse'});
} else {
this.parent.tab.append_row(); this.parent.tab.append_row();
}
var mytab = this.parent.tab;
// expand / collapse
if(this.opts.show_exp_img) {
this.exp_cell=$td(mytab,mytab.rows.length-2, 0);
$y(this.exp_cell, {cursor:'pointer', textAlign:'center', verticalAlign:'middle',width:'20px'});
this.exp_cell.innerHTML = '&nbsp;';
} else {
// pass
}
this.create_expimage = function() {
if(!me.opts.show_exp_img) return; // no expand image
if(!me.expimage) {
me.exp_cell.innerHTML='';
me.expimage = $a(me.exp_cell, 'img');
me.expimage.src = me.exp_img ? me.exp_img : me.tree.exp_img;
me.expimage.onclick = me.toggle;
}
}
// label
this.label = $a($td(mytab, mytab.rows.length-2, tc-1), 'div');
$y(this.label, this.opts.label_style);
// image
if(this.opts.show_icon) { // for second row, where children will come icon to be included
var t2 = make_table($a(this.label,'div'), 1, 2, '100%', ['20px',null]);
$y(t2,{borderCollapse:'collapse'});
this.img_cell = $td(t2, 0, 0);
$y(this.img_cell, {cursor:'pointer',verticalAlign:'middle',width:'20px'});
if(!imagesrc) imagesrc = "lib/images/icons/folder.gif";
this.usrimg = $a(this.img_cell, 'img');
this.usrimg.src = imagesrc;
this.label = $td(t2, 0, 1);
$y(this.label,{verticalAlign:'middle'});
}

this.loading_div = $a($td(mytab, mytab.rows.length-1, this.opts.show_exp_img ? 1 : 0), "div", "comment", {fontSize:'11px'});
$dh(this.loading_div);
this.loading_div.innerHTML = 'Loading...';

this.body = $a($td(mytab, mytab.rows.length-1, this.opts.show_exp_img ? 1 : 0), "div", '', {overflow:'hidden', display:'none'});

this.select = function() {
me.show_selected();
if(me.onclick)me.onclick(me);
}

this.show_selected = function() {
if(me.tree.cur_node)me.tree.cur_node.deselect();
if(me.opts.onselect_style) $y(me.label,me.opts.onselect_style)
//me.label.style.fontWeight = 'bold';
me.tree.cur_node = me;
}
this.deselect = function() {
if(me.opts.ondeselect_style) $y(me.label,me.opts.ondeselect_style)
//me.label.style.fontWeight = 'normal';
me.tree.cur_node=null
}
this.expanded = 0;
this.toggle = function() {
if(me.expanded)
me.collapse();
else
me.expand();
}
this.collapse = function() {
me.expanded = 0;
$(me.body).slideUp();
me.expimage.src = me.exp_img ? me.exp_img : me.tree.exp_img;
}
this.expand = function() {
if(me.onexpand && !me.expanded_once){
me.onexpand(me);
if(!me.tree.do_animate) me.show_expanded(); // else to be called from expand (for animation)
} else {
me.show_expanded();
}
me.expanded = 1;
me.expanded_once = 1;
me.expimage.src = me.col_img ? me.col_img : me.tree.col_img;
}
this.show_expanded = function() {
if(me.tree.do_animate && (!keys(me.nodes).length)) return; // no children
$(me.body).slideDown();
}

this.setlabel = function(l) {
me.label.value = l;
me.label.innerHTML = l;
}

this.setlabel(this.text);

this.setcolor = function(c) {
this.backColor = c;
if(cur_node!=this)
$bg(this.body,this.backColor);
}
this.label.onclick= function(e) { me.select(); }
this.label.ondblclick = function(e) { me.select(); if(me.ondblclick)me.ondblclick(me); }
this.clear_child_nodes = function() {
if(this.tab){
this.tab.parentNode.removeChild(this.tab);
delete this.tab;
}
this.expanded_once = 0;
}
}

+ 0
- 88
public/js/legacy/wn/widgets/form/sidebar.js Visa fil

@@ -1,88 +0,0 @@
// Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
//
// MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

wn.widgets.form.sidebar = { Sidebar: function(form) {
var me = this;
this.form = form;
this.opts = {
sections: [

{
title: wn._('Assign'),
render: function(wrapper) {
me.form.assign_to = new wn.ui.form.AssignTo({
parent: $(wrapper),
frm: me.form
});
me.form.assign_to.refresh();
},
display: function() { return !me.form.doc.__islocal }
},
{
title: wn._('Attachments'),
render: function(wrapper) {
me.form.attachments = new wn.ui.form.Attachments({
parent: $(wrapper),
frm:me.form
});
me.form.attachments.refresh();
},
display: function() { return me.form.meta.allow_attach }
},

{
title: wn._('Comments'),
render: function(wrapper) {
new wn.widgets.form.sidebar.Comments(wrapper, me, me.form.doctype, me.form.docname);
},
display: function() {
$(cur_frm.body).find(".latest-comment").toggle(false);
return !me.form.doc.__islocal;
}
},

{
title: wn._('Tags'),
render: function(wrapper) {
me.form.taglist = new TagList(wrapper,
me.form.doc._user_tags ? me.form.doc._user_tags.split(',') : [],
me.form.doctype, me.form.docname, 0,
function() { });
},
display: function() { return !me.form.doc.__islocal }
},
]
}
this.refresh = function() {
var parent = this.form.sidebar_area;
if(!this.sidebar) {
//$y(parent, {paddingTop:'37px'})
this.sidebar = new wn.widgets.PageSidebar(parent, this.opts);
} else {
this.sidebar.refresh();
}
}

}}

+ 0
- 151
public/js/legacy/wn/widgets/page_sidebar.js Visa fil

@@ -1,151 +0,0 @@
// Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
//
// MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

// opts = { 'title': 'My Sidebar',
// 'sections': [
// {'title': 'Actions',
// 'items': [{type: , label:, onclick function / string to eval], ]
// 'render': function (optional)
// }
//
// item types = link, button, html, inpu


//
// Page Sidebar
//
wn.widgets.PageSidebar = function(parent, opts) {
this.opts = opts
this.sections = {}
this.wrapper = $a(parent, 'div', 'psidebar')

// refresh sidebar - make head and sections
this.refresh = function() {
this.wrapper.innerHTML = ''
if(this.opts.title)
this.make_head();
for(var i=0; i<this.opts.sections.length; i++) {
var section = this.opts.sections[i];

if((section.display && section.display()) || !section.display) {
this.sections[section.title]
= new wn.widgets.PageSidebarSection(this, section);
}
}
if(this.opts.onrefresh) { this.opts.onrefresh(this) }
}

this.make_head = function() {
this.head = $a(this.wrapper, 'div', 'head', '', this.opts.title);
}
this.refresh();
}

//
// Sidebar Section
//
wn.widgets.PageSidebarSection = function(sidebar, opts) {
this.items = [];
this.sidebar = sidebar;
this.wrapper = $a(sidebar.wrapper, 'div', 'section');
this.head = $a(this.wrapper, 'div', 'section-head', '', opts.title);
this.body = $a(this.wrapper, 'div', 'section-body');
$br(this.wrapper, '5px');
this.opts = opts;


// make items
this.make_items = function() {
for(var i=0; i<this.opts.items.length; i++) {
var item = this.opts.items[i];
if((item.display && item.display()) || !item.display) {
var div = $a(this.body, 'div', 'section-item small');
this.make_one_item(item, div);
}
}
}

this.make_one_item = function(item, div) {
if (item.type.toLowerCase()=='link')
this.items[item.label] = new wn.widgets.PageSidebarLink(this, item, div);

else if (item.type.toLowerCase()=='button')
this.items[item.label] = new wn.widgets.PageSidebarButton(this, this.opts.items[i], div);

//else if (item.type=='Input')
// new wn.widgets.PageSidebarInput(this, this.opts.items[i], div);

else if (item.type.toLowerCase()=='html')
this.items[item.label] = new wn.widgets.PageSidebarHTML(this, this.opts.items[i], div);
}
// image
this.add_icon = function(parent, icon) {
var img = $a(parent, 'i', icon, {display:'inline-block', width:'20px'});
}
this.refresh = function() {
this.body.innerHTML = '';
if(this.opts.render) {
this.opts.render(this.body); }
else
this.make_items();
}
this.refresh();
}
//
// Elements
//

// link
wn.widgets.PageSidebarLink = function(section, opts, wrapper) {
this.wrapper = wrapper;
this.section = section;
this.opts = opts;
var me = this;
if(opts.icon) {
section.add_icon(this.wrapper, opts.icon);
}
this.ln = $a(this.wrapper, 'span', 'link_type section-link', opts.style, opts.label);
this.ln.onclick = function() { me.opts.onclick(me) };
}

// button
wn.widgets.PageSidebarButton = function(section, opts, wrapper) {
this.wrapper = wrapper;
this.section = section;
this.opts = opts;
var me = this;
this.btn = $btn(this.wrapper, opts.label, opts.onclick, opts.style, opts.color);
}

// html
wn.widgets.PageSidebarHTML = function(section, opts, wrapper) {
wrapper.innerHTML = opts.content
}

+ 1
- 1
public/js/lib/bootstrap.min.js
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 2
- 1
public/js/wn/form/control.js Visa fil

@@ -65,7 +65,8 @@ wn.ui.form.Control = Class.extend({
undefined; undefined;
}, },
set_model_value: function(value) { set_model_value: function(value) {
if(wn.model.set_value(this.doctype, this.docname, this.df.fieldname, value)) {
if(wn.model.set_value(this.doctype, this.docname, this.df.fieldname,
value, this.df.fieldtype)) {
this.frm && this.frm.dirty(); this.frm && this.frm.dirty();
this.last_value = value; this.last_value = value;
} }


+ 90
- 0
public/js/wn/form/dashboard.js Visa fil

@@ -0,0 +1,90 @@
wn.ui.form.Dashboard = Class.extend({
init: function(opts) {
$.extend(this, opts);
this.wrapper = $('<div class="form-dashboard row"></div>')
.prependTo(this.frm.layout.wrapper);
this.body = $('<div></div>').appendTo(this.wrapper);
},
reset: function() {
this.wrapper.toggle(false);
this.body.empty();
this.headline = null;
},
set_headline: function(html) {
if(!this.headline)
this.headline =
$('<div class="form-headline col col-lg-12">').prependTo(this.body);
this.headline.html(html);
this.wrapper.toggle(true);
},
set_headline_alert: function(text, alert_class, icon) {
this.set_headline(repl('<div class="alert %(alert_class)s">%(icon)s%(text)s</div>', {
"alert_class": alert_class || "",
"icon": icon ? '<i class="'+icon+'" /> ' : "",
"text": text
}));
},
add_doctype_badge: function(doctype, fieldname) {
if(wn.model.can_read(doctype)) {
this.add_badge(wn._(doctype), function() {
wn.route_options = {};
wn.route_options[fieldname] = cur_frm.doc.name;
wn.set_route("List", doctype);
}).attr("data-doctype", doctype);
}
},
add_badge: function(label, onclick) {
var badge = $(repl('<div class="col col-lg-4">\
<div class="alert alert-badge">\
<a class="badge-link">%(label)s</a>\
<span class="badge pull-right">-</span>\
</div></div>', {label:label}))
.appendTo(this.body)
badge.find(".badge-link").click(onclick);
this.wrapper.toggle(true);
return badge.find(".alert-badge");
},
set_badge_count: function(data) {
var me = this;
$.each(data, function(doctype, count) {
$(me.wrapper)
.find(".alert-badge[data-doctype='"+doctype+"'] .badge")
.html(cint(count));
});
},
add_progress: function(title, percent) {
var width = cint(percent) < 1 ? 1 : percent;
var progress_class = "";
if(width < 10)
progress_class = "progress-bar-danger";
if(width > 99.9)
progress_class = "progress-bar-success";
var progress_area = this.body.find(".progress-area");
if(!progress_area.length) {
progress_area = $('<div class="progress-area">').appendTo(this.body);
}
$(repl('<div class="progress-chart">\
<h5>%(title)s</h5>\
<div class="progress">\
<div class="progress-bar %(progress_class)s" style="width: %(width)s%"></div>\
</div>\
</div>', {
title:title,
width: width,
progress_class: progress_class
})).appendTo(progress_area);
var n_charts = progress_area.find(".progress-chart").length,
cols = Math.floor(12 / n_charts);
progress_area.find(".progress-chart")
.removeClass().addClass("progress-chart col col-lg-" + cols);
this.wrapper.toggle(true);
}
})

+ 3
- 1
public/js/wn/form/grid.js Visa fil

@@ -163,7 +163,7 @@ wn.ui.form.GridRow = Class.extend({
<button class="btn btn-success pull-right" \ <button class="btn btn-success pull-right" \
title="'+wn._("Close")+'"\ title="'+wn._("Close")+'"\
style="margin-left: 7px;">\ style="margin-left: 7px;">\
<i class="icon-ok"></i></button>\
<i class="icon-chevron-up"></i></button>\
<button class="btn btn-default pull-right grid-insert-row" \ <button class="btn btn-default pull-right grid-insert-row" \
title="'+wn._("Insert Row")+'"\ title="'+wn._("Insert Row")+'"\
style="margin-left: 7px;">\ style="margin-left: 7px;">\
@@ -273,6 +273,8 @@ wn.ui.form.GridRow = Class.extend({
$col.css({"text-align": "right"}) $col.css({"text-align": "right"})
} }
}); });

$(this.frm.wrapper).trigger("grid-row-render", [this]);
}, },
toggle_view: function(show, callback) { toggle_view: function(show, callback) {
this.doc = locals[this.doc.doctype][this.doc.name]; this.doc = locals[this.doc.doctype][this.doc.name];


+ 59
- 3
public/js/wn/form/layout.js Visa fil

@@ -1,5 +1,6 @@
wn.ui.form.Layout = Class.extend({ wn.ui.form.Layout = Class.extend({
init: function(opts) { init: function(opts) {
this.labelled_section_count = 0;
this.ignore_types = ["Section Break", "Column Break"]; this.ignore_types = ["Section Break", "Column Break"];
$.extend(this, opts); $.extend(this, opts);
this.make(); this.make();
@@ -45,7 +46,7 @@ wn.ui.form.Layout = Class.extend({
<form>\ <form>\
<fieldset></fieldset>\ <fieldset></fieldset>\
</form>\ </form>\
</div>').appendTo(this.section)
</div>').appendTo(this.section.body)
.find("form") .find("form")
.on("submit", function() { return false; }) .on("submit", function() { return false; })
.find("fieldset"); .find("fieldset");
@@ -67,22 +68,43 @@ wn.ui.form.Layout = Class.extend({
if(this.section) { if(this.section) {
//$("<hr>").appendTo(this.wrapper); //$("<hr>").appendTo(this.wrapper);
} }
this.section = $('<div class="row">').appendTo(this.wrapper);
this.section = $('<div class="row">')
.appendTo(this.wrapper);
this.frm.sections.push(this.section); this.frm.sections.push(this.section);
var section = this.section[0]; var section = this.section[0];
section.df = df; section.df = df;
if(df) { if(df) {
if(df.label) { if(df.label) {
$('<h3 class="col col-lg-12">' + df.label + "</h3>").appendTo(this.section);
this.labelled_section_count++;
$('<h3 class="col col-lg-12">'
+ (df.options ? (' <i class="text-muted '+df.options+'"></i> ') : "")
+ this.labelled_section_count + ". "
+ df.label
+ "</h3>")
.css({
"font-weight": "bold",
})
.appendTo(this.section);
if(this.frm.sections.length > 1)
this.section.css({
"margin-top": "15px",
"border-top": "1px solid #ddd"
});
} }
if(df.description) { if(df.description) {
$('<div class="col col-lg-12 small text-muted">' + df.description + '</div>').appendTo(this.section); $('<div class="col col-lg-12 small text-muted">' + df.description + '</div>').appendTo(this.section);
} }
if(df.label || df.description) {
$('<div class="col col-lg-12"></div>')
.appendTo(this.section)
.css({"height": "20px"});
}
this.frm.fields_dict[df.fieldname] = section; this.frm.fields_dict[df.fieldname] = section;
this.frm.fields.push(section); this.frm.fields.push(section);
} }
// for bc // for bc
this.section.body = $('<div style="padding: 0px 3%">').appendTo(this.section);
section.row = { section.row = {
wrapper: section wrapper: section
}; };
@@ -174,4 +196,38 @@ wn.ui.form.Layout = Class.extend({
get_open_grid_row: function() { get_open_grid_row: function() {
return $(".grid-row-open").data("grid_row"); return $(".grid-row-open").data("grid_row");
}, },
// dashboard
clear_dashboard: function() {
this.dashboard.empty();
},
add_doctype_badge: function(doctype, fieldname) {
if(wn.model.can_read(doctype)) {
this.add_badge(wn._(doctype), function() {
wn.route_options = {};
wn.route_options[fieldname] = cur_frm.doc.name;
wn.set_route("List", doctype);
}).attr("data-doctype", doctype);
}
},
add_badge: function(label, onclick) {
var badge = $(repl('<div class="col col-lg-4">\
<div class="alert alert-badge">\
<a class="badge-link">%(label)s</a>\
<span class="badge pull-right">-</span>\
</div></div>', {label:label}))
.appendTo(this.dashboard)
badge.find(".badge-link").click(onclick);
return badge.find(".alert-badge");
},
set_badge_count: function(data) {
var me = this;
$.each(data, function(doctype, count) {
$(me.dashboard)
.find(".alert-badge[data-doctype='"+doctype+"'] .badge")
.html(cint(count));
});
},
}) })

+ 15
- 6
public/js/wn/form/toolbar.js Visa fil

@@ -34,6 +34,7 @@ wn.ui.form.Toolbar = Class.extend({
title = title.substr(0,30) + "..."; title = title.substr(0,30) + "...";
} }
this.appframe.set_title(title, wn._(this.frm.docname)); this.appframe.set_title(title, wn._(this.frm.docname));
this.appframe.set_sub_title(wn._(this.frm.doctype));
}, },
show_infobar: function() { show_infobar: function() {
/* docs: /* docs:
@@ -63,8 +64,10 @@ wn.ui.form.Toolbar = Class.extend({
attachments = keys(docinfo.attachments).length, attachments = keys(docinfo.attachments).length,
assignments = docinfo.assignments.length; assignments = docinfo.assignments.length;
var $li1 = this.appframe.add_infobar(comments + " " + (comments===1 ?
wn._("Comment") : wn._("Comments")),
var $li1 = this.appframe.add_infobar(
(comments ? '<i class="icon-comments" style="font-size: 120%; color: orange"></i> ' : '')
+ comments + " "
+ (comments===1 ? wn._("Comment") : wn._("Comments")),
function() { function() {
$('html, body').animate({ $('html, body').animate({
scrollTop: $(me.frm.wrapper).find(".form-comments").offset().top scrollTop: $(me.frm.wrapper).find(".form-comments").offset().top
@@ -146,7 +149,7 @@ wn.ui.form.Toolbar = Class.extend({
var status_bar_parent = this.frm.appframe.$w.find(".status-bar").empty(); var status_bar_parent = this.frm.appframe.$w.find(".status-bar").empty();
if(this.frm.meta.is_submittable && !this.frm.doc.__islocal) { if(this.frm.meta.is_submittable && !this.frm.doc.__islocal) {
var status_bar = $("<h4>") var status_bar = $("<h4>")
.css({"margin": "0px"})
.css({"margin": "0px", "margin-top": "-15px"})
.appendTo(status_bar_parent); .appendTo(status_bar_parent);


switch(this.frm.doc.docstatus) { switch(this.frm.doc.docstatus) {
@@ -249,7 +252,9 @@ wn.ui.form.Toolbar = Class.extend({
if(docstatus==0 && p[SUBMIT] && (!me.frm.doc.__islocal) if(docstatus==0 && p[SUBMIT] && (!me.frm.doc.__islocal)
&& (!me.frm.doc.__unsaved)) { && (!me.frm.doc.__unsaved)) {
this.appframe.add_button('Submit', function() { this.appframe.add_button('Submit', function() {
me.frm.savesubmit(this);}, 'icon-lock', true).addClass("btn-primary");
me.frm.savesubmit(this);}, 'icon-lock', true)
.removeClass("btn-default")
.addClass("btn-primary");
} }
else if(docstatus==0) { else if(docstatus==0) {
this.make_save_button(); this.make_save_button();
@@ -269,7 +274,9 @@ wn.ui.form.Toolbar = Class.extend({
return; return;
var me = this; var me = this;
this.appframe.add_button('Save', function() { this.appframe.add_button('Save', function() {
me.frm.save('Save', null, this);}, 'icon-save', true).addClass("btn-primary");
me.frm.save('Save', null, this);}, 'icon-save', true)
.removeClass("btn-default")
.addClass("btn-primary");
}, },
add_update_button_on_dirty: function() { add_update_button_on_dirty: function() {
var me = this; var me = this;
@@ -282,7 +289,9 @@ wn.ui.form.Toolbar = Class.extend({
&& !me.appframe.$w.find(".action-update").length) { && !me.appframe.$w.find(".action-update").length) {
me.appframe.add_button("Update", function() { me.appframe.add_button("Update", function() {
me.frm.save('Update', null, me); me.frm.save('Update', null, me);
}, 'icon-save', true).addClass("btn-primary action-update");
}, 'icon-save', true)
.removeClass("btn-default")
.addClass("btn-primary action-update");
} }
}) })
}, },


+ 3
- 2
public/js/wn/misc/user.js Visa fil

@@ -19,12 +19,13 @@ wn.avatar = function(user, large, title) {
var to_size = large ? 72 : 30; var to_size = large ? 72 : 30;
if(!title) title = wn.user_info(user).fullname; if(!title) title = wn.user_info(user).fullname;


return repl('<span class="avatar" title="%(title)s" style="width: %(len)s; \
return repl('<span class="avatar %(small_or_large)s" title="%(title)s" style="width: %(len)s; \
height: %(len)s; border-radius: %(len)s; overflow: hidden;">\ height: %(len)s; border-radius: %(len)s; overflow: hidden;">\
<img src="%(image)s"></span>', { <img src="%(image)s"></span>', {
image: image, image: image,
len: to_size + "px", len: to_size + "px",
title: title
title: title,
small_or_large: large ? "avatar-large" : "avatar-small"
}); });
} }




+ 48
- 17
public/js/wn/model/create_new.js Visa fil

@@ -4,7 +4,7 @@ $.extend(wn.model, {
new_names: {}, new_names: {},
new_name_count: {}, new_name_count: {},


get_new_doc: function(doctype) {
get_new_doc: function(doctype, parent_doc) {
wn.provide("locals." + doctype); wn.provide("locals." + doctype);
var doc = { var doc = {
docstatus: 0, docstatus: 0,
@@ -14,10 +14,10 @@ $.extend(wn.model, {
__unsaved: 1, __unsaved: 1,
owner: user owner: user
}; };
wn.model.set_default_values(doc);
wn.model.set_default_values(doc, parent_doc);
locals[doctype][doc.name] = doc; locals[doctype][doc.name] = doc;
wn.provide("wn.model.docinfo." + doctype + "." + doc.name); wn.provide("wn.model.docinfo." + doctype + "." + doc.name);
return doc;
return doc;
}, },
make_new_doc_and_get_name: function(doctype) { make_new_doc_and_get_name: function(doctype) {
@@ -32,7 +32,7 @@ $.extend(wn.model, {
return 'New '+ doctype + ' ' + cnt[doctype]; return 'New '+ doctype + ' ' + cnt[doctype];
}, },
set_default_values: function(doc) {
set_default_values: function(doc, parent_doc) {
var doctype = doc.doctype; var doctype = doc.doctype;
var docfields = wn.meta.docfield_list[doctype] || []; var docfields = wn.meta.docfield_list[doctype] || [];
var updated = []; var updated = [];
@@ -40,7 +40,7 @@ $.extend(wn.model, {
for(var fid=0;fid<docfields.length;fid++) { for(var fid=0;fid<docfields.length;fid++) {
var f = docfields[fid]; var f = docfields[fid];
if(!in_list(wn.model.no_value_type, f.fieldtype) && doc[f.fieldname]==null) { if(!in_list(wn.model.no_value_type, f.fieldtype) && doc[f.fieldname]==null) {
var v = wn.model.get_default_value(f, doc);
var v = wn.model.get_default_value(f, doc, parent_doc);
if(v) { if(v) {
if(in_list(["Int", "Check"], f.fieldtype)) if(in_list(["Int", "Check"], f.fieldtype))
v = cint(v); v = cint(v);
@@ -55,32 +55,31 @@ $.extend(wn.model, {
return updated; return updated;
}, },
get_default_value: function(df, doc) {
get_default_value: function(df, doc, parent_doc) {
var def_vals = { var def_vals = {
"_Login": user,
"__user": user, "__user": user,
"Today": dateutil.get_today(), "Today": dateutil.get_today(),
"__today": dateutil.get_today(),
"Now": dateutil.get_cur_time()
} }
if(def_vals[df["default"]])
if(wn.defaults.get_user_default(df.fieldname))
return wn.defaults.get_user_default(df.fieldname);
else if(df["default"] && df["default"][0]===":")
return wn.model.get_default_from_boot_docs(df, doc, parent_doc);
else if(def_vals[df["default"]])
return def_vals[df["default"]]; return def_vals[df["default"]];
else if(df.fieldtype=="Time" && (!df["default"])) else if(df.fieldtype=="Time" && (!df["default"]))
return dateutil.get_cur_time() return dateutil.get_cur_time()
else if(df["default"] && df["default"][0]!==":") else if(df["default"] && df["default"][0]!==":")
return df["default"]; return df["default"];
else if(wn.defaults.get_user_default(df.fieldname))
return wn.defaults.get_user_default(df.fieldname);
else if(df["default"] && df["default"][0]===":")
return wn.model.get_default_from_boot_docs(df, doc);
}, },
get_default_from_boot_docs: function(df, doc) {
get_default_from_boot_docs: function(df, doc, parent_doc) {
// set default from partial docs passed during boot like ":Profile" // set default from partial docs passed during boot like ":Profile"
if(wn.model.get(df["default"]).length > 0) { if(wn.model.get(df["default"]).length > 0) {
var ref_fieldname = df["default"].slice(1).toLowerCase().replace(" ", "_"); var ref_fieldname = df["default"].slice(1).toLowerCase().replace(" ", "_");
var ref_value = (doc && doc[ref_fieldname]) || (cur_frm && cur_frm.doc[ref_fieldname]);
var ref_value = parent_doc ?
parent_doc[ref_fieldname] :
wn.defaults.get_user_default(ref_fieldname);
var ref_doc = ref_value ? wn.model.get_doc(df["default"], ref_value) : null; var ref_doc = ref_value ? wn.model.get_doc(df["default"], ref_value) : null;
if(ref_doc && ref_doc[df.fieldname]) { if(ref_doc && ref_doc[df.fieldname]) {
@@ -96,7 +95,7 @@ $.extend(wn.model, {
wn.model.get_children(doctype, parent_doc.name, parentfield, wn.model.get_children(doctype, parent_doc.name, parentfield,
parent_doc.doctype).length + 1; parent_doc.doctype).length + 1;


var d = wn.model.get_new_doc(doctype);
var d = wn.model.get_new_doc(doctype, parent_doc);
$.extend(d, { $.extend(d, {
parent: parent_doc.name, parent: parent_doc.name,
parentfield: parentfield, parentfield: parentfield,
@@ -129,4 +128,36 @@ $.extend(wn.model, {
return newdoc; return newdoc;
}, },
open_mapped_doc: function(opts) {
wn.call({
type: "GET",
method: opts.method,
args: {
"source_name": opts.source_name
},
callback: function(r) {
if(!r.exc) {
var doclist = wn.model.sync(r.message);
wn.set_route("Form", doclist[0].doctype, doclist[0].name);
}
}
})
},

map_current_doc: function(opts) {
wn.call({
type: "GET",
method: opts.method,
args: {
"source_name": opts.source_name,
"target_doclist": wn.model.get_doclist(cur_frm.doc.doctype, cur_frm.doc.name)
},
callback: function(r) {
if(!r.exc) {
var doclist = wn.model.sync(r.message);
cur_frm.refresh();
}
}
});
}
}) })

+ 5
- 1
public/js/wn/model/model.js Visa fil

@@ -193,13 +193,17 @@ $.extend(wn.model, {
} }
}, },
set_value: function(doctype, name, fieldname, value) {
set_value: function(doctype, name, fieldname, value, fieldtype) {
/* help: Set a value locally (if changed) and execute triggers */ /* help: Set a value locally (if changed) and execute triggers */
var doc = locals[doctype] && locals[doctype][name] || null; var doc = locals[doctype] && locals[doctype][name] || null;
if(doc && doc[fieldname] !== value) { if(doc && doc[fieldname] !== value) {
doc[fieldname] = value; doc[fieldname] = value;
wn.model.trigger(fieldname, value, doc); wn.model.trigger(fieldname, value, doc);
return true; return true;
} else {
// execute link triggers (want to reselect to execute triggers)
if(fieldtype=="Link")
wn.model.trigger(fieldname, value, doc);
} }
}, },


+ 12
- 2
public/js/wn/model/sync.js Visa fil

@@ -35,10 +35,20 @@ $.extend(wn.model, {
if(doclist && doclist.length) if(doclist && doclist.length)
wn.model.clear_doclist(doclist[0].doctype, doclist[0].name) wn.model.clear_doclist(doclist[0].doctype, doclist[0].name)


var last_parent_name = null;
$.each(doclist, function(i, d) { $.each(doclist, function(i, d) {
if(!d.name) // get name (local if required)
if(!d.name && d.__islocal) { // get name (local if required)
d.name = wn.model.get_new_name(d.doctype); d.name = wn.model.get_new_name(d.doctype);
wn.provide("wn.model.docinfo." + d.doctype + "." + d.name);
if(!d.parenttype)
last_parent_name = d.name;
}

// set parent for subsequent orphans
if(d.parenttype && !d.parent && d.__islocal) {
d.parent = last_parent_name;
}

if(!locals[d.doctype]) if(!locals[d.doctype])
locals[d.doctype] = {}; locals[d.doctype] = {};




+ 11
- 4
public/js/wn/ui/appframe.js Visa fil

@@ -19,8 +19,7 @@ wn.ui.AppFrame = Class.extend({
<div class="title-area"><h2 style="display: inline-block">\ <div class="title-area"><h2 style="display: inline-block">\
<span class="title-icon" style="display: none"></span>\ <span class="title-icon" style="display: none"></span>\
<span class="title-text"></span></h2></div>\ <span class="title-text"></span></h2></div>\
<div class="sub-title-area text-muted small" \
style="margin-top: -10px;"></div>\
<div class="sub-title-area text-muted small">&nbsp;</div>\
<div class="status-bar"></div>\ <div class="status-bar"></div>\
</div>\ </div>\
</div>\ </div>\
@@ -71,6 +70,13 @@ wn.ui.AppFrame = Class.extend({
add_module_icon: function(module) { add_module_icon: function(module) {
var module_info = wn.modules[module]; var module_info = wn.modules[module];
if(!module_info) {
module_info = {
icon: "icon-question-sign",
color: "#eeeeee"
}
}
if(module_info && module_info.icon) { if(module_info && module_info.icon) {
this.$w.find(".title-icon").html('<i class="' this.$w.find(".title-icon").html('<i class="'
+module_info.icon+'"></i> ') +module_info.icon+'"></i> ')
@@ -80,7 +86,8 @@ wn.ui.AppFrame = Class.extend({
}) })
.attr("module-name", module) .attr("module-name", module)
.click(function() { .click(function() {
wn.set_route(wn.modules[$(this).attr("module-name")].link);
var module_info = wn.modules[$(this).attr("module-name")];
wn.set_route(module_info ? module_info.link : "desktop");
}); });
} }
}, },
@@ -165,7 +172,7 @@ wn.ui.AppFrame = Class.extend({
.appendTo($right); .appendTo($right);
if(e.type==active_view) { if(e.type==active_view) {
btn.addClass("btn-info");
btn.removeClass("btn-default").addClass("btn-info");
} }
}); });
}, },


+ 1
- 1
public/js/wn/ui/field_group.js Visa fil

@@ -53,7 +53,7 @@ wn.ui.FieldGroup = Class.extend({
// first button primary ? // first button primary ?
if(df.fieldtype=='Button' && !this.first_button) { if(df.fieldtype=='Button' && !this.first_button) {
$(f.input).addClass('btn-info');
$(f.input).removeClass("btn-default").addClass('btn-info');
this.first_button = true; this.first_button = true;
} }
} }


+ 13
- 3
public/js/wn/ui/listing.js Visa fil

@@ -173,7 +173,7 @@ wn.ui.Listing = Class.extend({
// new // new
if(this.new_doctype) { if(this.new_doctype) {
this.add_button(wn._('New') + ' ' + wn._(this.new_doctype), function() { this.add_button(wn._('New') + ' ' + wn._(this.new_doctype), function() {
(me.custom_new_doc || me.make_new_doc)(me.new_doctype);
(me.custom_new_doc || me.make_new_doc).apply(me, [me.new_doctype]);
}, 'icon-plus'); }, 'icon-plus');
} }
@@ -189,8 +189,18 @@ wn.ui.Listing = Class.extend({
} }
}, },
make_new_doc: function(new_doctype) {
new_doc(new_doctype);
make_new_doc: function(doctype) {
var me = this;
wn.model.with_doctype(doctype, function() {
var doc = wn.model.get_new_doc(doctype);
if(me.filter_list) {
$.each(me.filter_list.get_filters(), function(i, f) {
if(f[0]===doctype && f[2]==="=")
doc[f[1]]=f[3];
})
}
wn.set_route("Form", doctype, doc.name);
});
}, },


make_filters: function() { make_filters: function() {


+ 1
- 1
public/js/wn/views/communication.js Visa fil

@@ -42,7 +42,7 @@ wn.views.CommunicationList = Class.extend({
.empty() .empty()
.css({"margin":"10px 0px"}); .css({"margin":"10px 0px"});
this.wrapper = $("<div><h4>"+wn._("Communication History")+"</h4>\
this.wrapper = $("<div>\
<div style='margin-bottom: 8px;'>\ <div style='margin-bottom: 8px;'>\
<button class='btn btn-default' \ <button class='btn btn-default' \
onclick='cur_frm.communication_view.add_reply()'>\ onclick='cur_frm.communication_view.add_reply()'>\


+ 3
- 2
public/js/wn/views/doclistview.js Visa fil

@@ -149,7 +149,7 @@ wn.views.DocListView = wn.ui.Listing.extend({
// make_new_doc can be overridden so that default values can be prefilled // make_new_doc can be overridden so that default values can be prefilled
// for example - communication list in customer // for example - communication list in customer
$(this.wrapper).on("click", 'button[list_view_doc="'+me.doctype+'"]', function(){ $(this.wrapper).on("click", 'button[list_view_doc="'+me.doctype+'"]', function(){
(me.listview.make_new_doc || me.make_new_doc)(me.doctype);
(me.listview.make_new_doc || me.make_new_doc).apply(me, [me.doctype]);
}); });
if((auto_run !== false) && (auto_run !== 0)) if((auto_run !== false) && (auto_run !== 0))
@@ -190,7 +190,7 @@ wn.views.DocListView = wn.ui.Listing.extend({
make_no_result: function() { make_no_result: function() {
var new_button = wn.boot.profile.can_create.indexOf(this.doctype)!=-1 var new_button = wn.boot.profile.can_create.indexOf(this.doctype)!=-1
? ('<hr><p><button class="btn btn-default btn-info" \
? ('<hr><p><button class="btn btn-primary" \
list_view_doc="%(doctype)s">'+ list_view_doc="%(doctype)s">'+
wn._('Make a new') + ' %(doctype_label)s</button></p>') wn._('Make a new') + ' %(doctype_label)s</button></p>')
: ''; : '';
@@ -260,6 +260,7 @@ wn.views.DocListView = wn.ui.Listing.extend({
}, },
callback: function() { callback: function() {
me.set_working(false); me.set_working(false);
me.dirty = true;
me.refresh(); me.refresh();
} }
}) })


+ 14
- 11
public/js/wn/views/moduleview.js Visa fil

@@ -75,8 +75,10 @@ wn.views.moduleview.ModuleView = Class.extend({
add_section: function(section) { add_section: function(section) {
section._title = wn._(section.title); section._title = wn._(section.title);
if(section.top) { if(section.top) {
var module_top = $(this.wrapper).find(".module-top");
var list_group = $('<div>') var list_group = $('<div>')
.appendTo($(this.wrapper).find(".module-top"));
.appendTo(module_top);
$('<div class="col col-lg-12"><hr /></div>').appendTo(module_top);
} else { } else {
var list_group = $('<ul class="list-group">\ var list_group = $('<ul class="list-group">\
<li class="list-group-item">\ <li class="list-group-item">\
@@ -95,16 +97,16 @@ wn.views.moduleview.ModuleView = Class.extend({
if(item.count==null) item.count = ""; if(item.count==null) item.count = "";
if(section.top) { if(section.top) {
var $parent = $(repl('<div class="col col-lg-4">\ var $parent = $(repl('<div class="col col-lg-4">\
<div class="alert"></div>\
<div>\
<div class="module-item-progress" data-doctype="%(doctype)s">\
<div class="module-item-progress-total">\
<div class="module-item-progress-open">\
</div>\
</div>\
</div>\
</div>\
</div>', {doctype:item.doctype}))
<div class="alert alert-badge"></div>'
// <div>\
// <div class="module-item-progress" data-doctype="%(doctype)s">\
// <div class="module-item-progress-total">\
// <div class="module-item-progress-open">\
// </div>\
// </div>\
// </div>\
// </div>\
+'</div>', {doctype:item.doctype}))
.appendTo(section.list_group) .appendTo(section.list_group)
.find(".alert"); .find(".alert");
this.top_item_total[item.doctype] = 0; this.top_item_total[item.doctype] = 0;
@@ -129,6 +131,7 @@ wn.views.moduleview.ModuleView = Class.extend({
} }
}, },
set_top_item_count: function(doctype, count, open_count) { set_top_item_count: function(doctype, count, open_count) {
return;
var me = this; var me = this;
if(this.top_item_total[doctype]!=null) { if(this.top_item_total[doctype]!=null) {




+ 5
- 1
webnotes/__init__.py Visa fil

@@ -160,7 +160,7 @@ def connect(db_name=None, password=None):
import webnotes.profile import webnotes.profile
global user global user
user = webnotes.profile.Profile('Administrator') user = webnotes.profile.Profile('Administrator')
def get_env_vars(env_var): def get_env_vars(env_var):
import os import os
return os.environ.get(env_var,'None') return os.environ.get(env_var,'None')
@@ -300,6 +300,10 @@ def doc(doctype=None, name=None, fielddata=None):
from webnotes.model.doc import Document from webnotes.model.doc import Document
return Document(doctype, name, fielddata) return Document(doctype, name, fielddata)


def new_doc(doctype, parent_doc=None, parentfield=None):
from webnotes.model.create_new import get_new_doc
return get_new_doc(doctype, parent_doc, parentfield)

def doclist(lst=None): def doclist(lst=None):
from webnotes.model.doclist import DocList from webnotes.model.doclist import DocList
return DocList(lst) return DocList(lst)


+ 3
- 1
webnotes/client.py Visa fil

@@ -90,4 +90,6 @@ def set_default(key, value, parent=None):
def make_width_property_setter(): def make_width_property_setter():
doclist = json.loads(webnotes.form_dict.doclist) doclist = json.loads(webnotes.form_dict.doclist)
if doclist[0]["doctype"]=="Property Setter" and doclist[0]["property"]=="width": if doclist[0]["doctype"]=="Property Setter" and doclist[0]["property"]=="width":
webnotes.bean(doclist).save()
bean = webnotes.bean(doclist)
bean.ignore_permissions = True
bean.insert()

+ 10
- 3
webnotes/db.py Visa fil

@@ -369,9 +369,16 @@ class Database:
return r and [[i[1] for i in r]] or [] return r and [[i[1] for i in r]] or []
def get_values_from_table(self, fields, filters, doctype, as_dict, debug): def get_values_from_table(self, fields, filters, doctype, as_dict, debug):
fl = fields
if fields!="*":
fl = ("`" + "`, `".join(fields) + "`")
fl = []
if isinstance(fields, (list, tuple)):
for f in fields:
if "(" in f: # function
fl.append(f)
else:
fl.append("`" + f + "`")
fl = ", ".join(fields)
else:
fl = fields


conditions, filters = self.build_conditions(filters) conditions, filters = self.build_conditions(filters)


+ 3
- 1
webnotes/handler.py Visa fil

@@ -91,7 +91,9 @@ def dt_map():
from_to_list = form_dict.get('from_to_list') from_to_list = form_dict.get('from_to_list')
dm = get_obj('DocType Mapper', from_doctype +'-' + to_doctype) dm = get_obj('DocType Mapper', from_doctype +'-' + to_doctype)
dl = dm.dt_map(from_doctype, to_doctype, from_docname, Document(fielddata = dt_list[0]), (len(dt_list) > 1) and Bean(dt_list).doclist or [], from_to_list)
dl = dm.dt_map(from_doctype, to_doctype, from_docname,
Document(fielddata = dt_list[0]),
(len(dt_list) > 1) and Bean(dt_list).doclist or [], from_to_list)
webnotes.response['docs'] = dl webnotes.response['docs'] = dl




+ 0
- 1
webnotes/model/bean.py Visa fil

@@ -77,7 +77,6 @@ class Bean:
doclist += getchildren(doc.name, t[0], t[1], dt, prefix=prefix) doclist += getchildren(doc.name, t[0], t[1], dt, prefix=prefix)


self.set_doclist(doclist) self.set_doclist(doclist)
self.run_method("onload")


def __iter__(self): def __iter__(self):
return self.doclist.__iter__() return self.doclist.__iter__()


+ 53
- 0
webnotes/model/create_new.py Visa fil

@@ -0,0 +1,53 @@
from __future__ import unicode_literals
"""
Create a new document with defaults set
"""

import webnotes
from webnotes.utils import nowdate, nowtime, cint, flt

def get_new_doc(doctype, parent_doc = None, parentfield = None):
doc = webnotes.doc({
"doctype": doctype,
"__islocal": 1
})
meta = webnotes.get_doctype(doctype)
if parent_doc:
doc.parent = parent_doc.name
doc.parenttype = parent_doc.doctype
doc.parentfield = parentfield
for d in meta.get({"doctype":"DocField", "parent": doctype}):
default = webnotes.conn.get_default(d.fieldname)
if default:
doc.fields[d.fieldname] = default
elif d.fields.get("default"):
if d.default == "__user":
doc.fields[d.fieldname] = webnotes.session.user
elif d.default == "Today":
doc.fields[d.fieldname] = nowdate()

elif d.default.startswith(":"):
ref_fieldname = d.default[1:].lower().replace(" ", "_")
if parent_doc:
ref_docname = parent_doc.fields[ref_fieldname]
else:
ref_docname = webnotes.conn.get_default(ref_fieldname)
doc.fields[d.fieldname] = webnotes.conn.get_value(d.default[1:],
ref_docname, d.fieldname)

else:
doc.fields[d.fieldname] = d.default
# convert type of default
if d.fieldtype in ("Int", "Check"):
doc.fields[d.fieldname] = cint(doc.fields[d.fieldname])
elif d.fieldtype in ("Float", "Currency"):
doc.fields[d.fieldname] = flt(doc.fields[d.fieldname])
elif d.fieldtype == "Time":
doc.fields[d.fieldname] = nowtime()
return doc

+ 104
- 0
webnotes/model/mapper.py Visa fil

@@ -0,0 +1,104 @@
# Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
#
# MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

from __future__ import unicode_literals
import webnotes, json
from webnotes import _
from webnotes.utils import cstr
from webnotes.model import default_fields

def get_mapped_doclist(from_doctype, from_docname, table_maps, target_doclist=[], postprocess=None):
if isinstance(target_doclist, basestring):
target_doclist = json.loads(target_doclist)
if not webnotes.has_permission(from_doctype, from_docname):
webnotes.msgprint("No Permission", raise_exception=webnotes.PermissionError)

source = webnotes.bean(from_doctype, from_docname)

source_meta = webnotes.get_doctype(from_doctype)
target_meta = webnotes.get_doctype(table_maps[from_doctype]["doctype"])
# main
if target_doclist:
target_doc = webnotes.doc(target_doclist[0])
else:
target_doc = webnotes.new_doc(table_maps[from_doctype]["doctype"])
map_doc(source.doc, target_doc, table_maps[source.doc.doctype], source_meta, target_meta)
doclist = [target_doc]

# children
for source_d in source.doclist[1:]:
target_doctype = table_maps[source_d.doctype]["doctype"]
parentfield = target_meta.get({
"parent": target_doc.doctype,
"doctype": "DocField",
"fieldtype": "Table",
"options": target_doctype
})[0].fieldname
target_d = webnotes.new_doc(target_doctype, target_doc, parentfield)
map_doc(source_d, target_d, table_maps[source_d.doctype], source_meta, target_meta)
doclist.append(target_d)
if postprocess:
postprocess(source, doclist)
return doclist

def map_doc(source_doc, target_doc, table_map, source_meta, target_meta):
no_copy_fields = set(\
[d.fieldname for d in source_meta.get({"no_copy": 1,
"parent": source_doc.doctype})] \
+ [d.fieldname for d in target_meta.get({"no_copy": 1,
"parent": target_doc.doctype})] \
+ default_fields)

if table_map.get("validation"):
for key, condition in table_map["validation"].items():
if condition[0]=="=":
if source_doc.fields.get(key) != condition[1]:
webnotes.msgprint(_("Cannot map because following condition fails: ")
+ key + "=" + cstr(condition[1]), raise_exception=webnotes.ValidationError)

# map same fields
target_fields = target_meta.get({"doctype": "DocField", "parent": target_doc.doctype})
for key in [d.fieldname for d in target_fields]:
if key not in no_copy_fields:
val = source_doc.fields.get(key)
if val not in (None, ""):
target_doc.fields[key] = val

# map other fields
for source_key, target_key in table_map.get("field_map", {}).items():
val = source_doc.fields.get(source_key)
if val not in (None, ""):
target_doc.fields[target_key] = val

# map idx
if source_doc.idx:
target_doc.idx = source_doc.idx
if "postprocess" in table_map:
table_map["postprocess"](source_doc, target_doc)

+ 18
- 3
webnotes/widgets/form/load.py Visa fil

@@ -45,7 +45,11 @@ def getdoc(doctype, name, user=None):
return [] return []


try: try:
doclist = webnotes.bean(doctype, name).doclist
bean = webnotes.bean(doctype, name)
bean.run_method("onload")

doclist = bean.doclist

# add file list # add file list
set_docinfo(doctype, name) set_docinfo(doctype, name)
@@ -54,7 +58,7 @@ def getdoc(doctype, name, user=None):
webnotes.msgprint('Did not load.') webnotes.msgprint('Did not load.')
raise e raise e


if doclist and not name.startswith('_'):
if bean and not name.startswith('_'):
webnotes.user.update_recent(doctype, name) webnotes.user.update_recent(doctype, name)
webnotes.response['docs'] = doclist webnotes.response['docs'] = doclist
@@ -113,4 +117,15 @@ def add_assignments(dt, dn):
"name": dn "name": dn
}) })
return cl
return cl
@webnotes.whitelist()
def get_badge_info(doctypes, filters):
filters = json.loads(filters)
doctypes = json.loads(doctypes)
filters["docstatus"] = ["!=", 2]
out = {}
for doctype in doctypes:
out[doctype] = webnotes.conn.get_value(doctype, filters, "count(*)")

return out

+ 1
- 1
webnotes/widgets/form/run_method.py Visa fil

@@ -35,7 +35,7 @@ def runserverobj():


wrapper = None wrapper = None
method = webnotes.form_dict.get('method') method = webnotes.form_dict.get('method')
arg = webnotes.form_dict.get('arg')
arg = webnotes.form_dict.get('args')
dt = webnotes.form_dict.get('doctype') dt = webnotes.form_dict.get('doctype')
dn = webnotes.form_dict.get('docname') dn = webnotes.form_dict.get('docname')


+ 0
- 7
webnotes/widgets/moduleview.py Visa fil

@@ -27,13 +27,6 @@ def get_doctype_count_from_table(doctype):
else: else:
raise e raise e
return count return count

def get_doctype_count(doctype):
count = webnotes.conn.get_global("item_count:" + doctype)
if count is None:
count = get_doctype_count_from_table(doctype)
webnotes.conn.set_global("item_count:" + doctype, count)
return count
def get_report_list(module): def get_report_list(module):
"""return list on new style reports for modules""" """return list on new style reports for modules"""


Laddar…
Avbryt
Spara