You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

97 lines
3.5 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. // features
  23. // --------
  24. // toolbar - standard and custom
  25. // label - saved, submitted etc
  26. // save / submit button toggle based on "saved" or not
  27. // highlight and fade name based on refresh
  28. _f.FrmHeader = Class.extend({
  29. init: function(parent, frm) {
  30. this.appframe = frm.appframe;
  31. this.$w = this.appframe.$w;
  32. this.frm = frm;
  33. this.appframe.add_home_breadcrumb();
  34. this.appframe.add_module_icon(frm.meta.module)
  35. this.appframe.set_views_for(frm.meta.name, "form");
  36. if(!frm.meta.issingle) {
  37. if(frm.cscript.add_list_breadcrumb) {
  38. frm.cscript.add_list_breadcrumb(this.appframe);
  39. } else {
  40. this.appframe.add_list_breadcrumb(frm.meta.name);
  41. }
  42. }
  43. this.appframe.add_breadcrumb("icon-file");
  44. },
  45. refresh: function() {
  46. var me = this;
  47. var title = this.frm.docname;
  48. if(title.length > 30) {
  49. title = title.substr(0,30) + "...";
  50. }
  51. this.appframe.set_title(title, wn._(this.frm.docname));
  52. this.appframe.set_sub_title(this.frm.doc.__islocal ? "Not Saved"
  53. : "Last Updated on " + dateutil.str_to_user(this.frm.doc.modified) + " by " + this.frm.doc.modified_by)
  54. //this.refresh_timestamps();
  55. },
  56. refresh_timestamps: function() {
  57. this.$w.find(".avatar").remove();
  58. var doc = this.frm.doc;
  59. if(doc.__islocal || !doc.owner || !doc.modified_by)
  60. return;
  61. $(repl('<span class="avatar avatar avatar-small">\
  62. <img title="%(created_by)s" src="%(avatar_created)s"/></span>\
  63. <span class="avatar avatar avatar-small">\
  64. <img title="%(modified_by)s" src="%(avatar_modified)s"/></span>', {
  65. created_by: wn.user_info(doc.owner).fullname,
  66. avatar_created: wn.utils.get_file_link(wn.user_info(doc.owner).image),
  67. modified_by: wn.user_info(doc.modified_by).fullname,
  68. avatar_modified: wn.utils.get_file_link(wn.user_info(doc.modified_by).image),
  69. })).insertAfter(this.$w.find(".appframe-title"));
  70. this.$w.find(".avatar:eq(0)").popover({
  71. trigger:"hover",
  72. title: wn._("Created By"),
  73. content: wn.user_info(this.frm.doc.owner).fullname
  74. +" on "+ dateutil.str_to_user(this.frm.doc.creation)
  75. });
  76. this.$w.find(".avatar:eq(1)").popover({
  77. trigger:"hover",
  78. title: wn._("Modified By"),
  79. content: wn.user_info(this.frm.doc.modified_by).fullname
  80. +" on "+ dateutil.str_to_user(this.frm.doc.modified)
  81. });
  82. this.$w.find('.avatar img').centerImage();
  83. },
  84. hide_close: function() {
  85. this.$w.find('.close').toggle(false);
  86. }
  87. })