Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

175 righe
4.7 KiB

  1. // Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
  2. //
  3. // MIT License (MIT)
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a
  6. // copy of this software and associated documentation files (the "Software"),
  7. // to deal in the Software without restriction, including without limitation
  8. // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. // and/or sell copies of the Software, and to permit persons to whom the
  10. // Software is furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  16. // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  17. // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18. // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  19. // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  20. // OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. //
  22. wn.widgets.form.sidebar = { Sidebar: function(form) {
  23. var me = this;
  24. this.form = form;
  25. this.opts = {
  26. sections: [
  27. {
  28. title: 'Actions',
  29. items: [
  30. {
  31. type: 'link',
  32. label: 'New',
  33. icon: 'icon-plus',
  34. display: function() {
  35. return in_list(profile.can_create, form.doctype)
  36. },
  37. onclick: function() { new_doc(me.form.doctype) }
  38. },
  39. {
  40. type: 'link',
  41. label: 'Print',
  42. display: function() {
  43. return !(me.form.doc.__islocal || me.form.meta.allow_print);
  44. },
  45. icon: 'icon-print',
  46. onclick: function() { me.form.print_doc() }
  47. },
  48. {
  49. type: 'link',
  50. label: 'Email',
  51. display: function() {
  52. return !(me.form.doc.__islocal || me.form.meta.allow_email);
  53. },
  54. icon: 'icon-envelope',
  55. onclick: function() { me.form.email_doc() }
  56. },
  57. {
  58. type: 'link',
  59. label: 'Copy',
  60. display: function() {
  61. return in_list(profile.can_create, me.form.doctype) && !me.form.meta.allow_copy
  62. },
  63. icon: 'icon-file',
  64. onclick: function() { me.form.copy_doc() }
  65. },
  66. {
  67. type: 'link',
  68. label: 'Delete',
  69. display: function() {
  70. return (cint(me.form.doc.docstatus) != 1) && !me.form.doc.__islocal
  71. && wn.model.can_delete(me.form.doctype);
  72. },
  73. icon: 'icon-remove-sign',
  74. onclick: function() { me.form.savetrash() }
  75. },
  76. {
  77. type: 'link',
  78. label: 'Rename',
  79. display: function() {
  80. return me.form.meta.allow_rename && me.form.perm[0][WRITE];
  81. },
  82. icon: 'icon-retweet',
  83. onclick: function() { me.form.rename_doc() }
  84. },
  85. {
  86. type: 'link',
  87. label: 'Linked With',
  88. display: function() {
  89. return !me.form.doc.__islocal && !me.form.meta.issingle;
  90. },
  91. icon: 'icon-link',
  92. onclick: function() {
  93. if(!me.form.linked_with) {
  94. me.form.linked_with = new wn.ui.form.LinkedWith({
  95. frm: me.form
  96. });
  97. }
  98. me.form.linked_with.show();
  99. }
  100. }
  101. ],
  102. display: function() {
  103. return me.form.meta.hide_toolbar ? false : true;
  104. }
  105. },
  106. {
  107. title: 'Assign',
  108. render: function(wrapper) {
  109. me.form.assign_to = new wn.ui.form.AssignTo({
  110. parent: $(wrapper),
  111. frm: me.form
  112. });
  113. me.form.assign_to.refresh();
  114. },
  115. display: function() { return !me.form.doc.__islocal }
  116. },
  117. {
  118. title: 'Attachments',
  119. render: function(wrapper) {
  120. me.form.attachments = new wn.ui.form.Attachments({
  121. parent: $(wrapper),
  122. frm:me.form
  123. });
  124. me.form.attachments.refresh();
  125. },
  126. display: function() { return me.form.meta.allow_attach }
  127. },
  128. {
  129. title: 'Comments',
  130. render: function(wrapper) {
  131. new wn.widgets.form.sidebar.Comments(wrapper, me, me.form.doctype, me.form.docname);
  132. },
  133. display: function() {
  134. $(cur_frm.page_layout.body).find(".latest-comment").toggle(false);
  135. return !me.form.doc.__islocal;
  136. }
  137. },
  138. {
  139. title: 'Tags',
  140. render: function(wrapper) {
  141. me.form.taglist = new TagList(wrapper,
  142. me.form.doc._user_tags ? me.form.doc._user_tags.split(',') : [],
  143. me.form.doctype, me.form.docname, 0,
  144. function() { });
  145. },
  146. display: function() { return !me.form.doc.__islocal }
  147. },
  148. ]
  149. }
  150. this.refresh = function() {
  151. var parent = this.form.page_layout.sidebar_area;
  152. if(!this.sidebar) {
  153. //$y(parent, {paddingTop:'37px'})
  154. this.sidebar = new wn.widgets.PageSidebar(parent, this.opts);
  155. } else {
  156. this.sidebar.refresh();
  157. }
  158. }
  159. }}