Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

sidebar.js 4.6 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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;
  90. },
  91. icon: 'icon-random',
  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 To',
  108. render: function(wrapper) {
  109. me.form.assign_to = new wn.widgets.form.sidebar.AssignTo(wrapper, me, me.form.doctype, me.form.docname);
  110. },
  111. display: function() { return !me.form.doc.__islocal }
  112. },
  113. {
  114. title: 'Attachments',
  115. render: function(wrapper) {
  116. me.form.attachments = new wn.widgets.form.sidebar.Attachments(wrapper, me, me.form.doctype, me.form.docname);
  117. },
  118. display: function() { return me.form.meta.allow_attach }
  119. },
  120. {
  121. title: 'Comments',
  122. render: function(wrapper) {
  123. new wn.widgets.form.sidebar.Comments(wrapper, me, me.form.doctype, me.form.docname);
  124. },
  125. display: function() {
  126. $(cur_frm.page_layout.body).find(".latest-comment").toggle(false);
  127. return !me.form.doc.__islocal;
  128. }
  129. },
  130. {
  131. title: 'Tags',
  132. render: function(wrapper) {
  133. me.form.taglist = new TagList(wrapper,
  134. me.form.doc._user_tags ? me.form.doc._user_tags.split(',') : [],
  135. me.form.doctype, me.form.docname, 0,
  136. function() { });
  137. },
  138. display: function() { return !me.form.doc.__islocal }
  139. },
  140. ]
  141. }
  142. this.refresh = function() {
  143. var parent = this.form.page_layout.sidebar_area;
  144. if(!this.sidebar) {
  145. //$y(parent, {paddingTop:'37px'})
  146. this.sidebar = new wn.widgets.PageSidebar(parent, this.opts);
  147. } else {
  148. this.sidebar.refresh();
  149. }
  150. }
  151. }}