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.

преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // for license information please see license.txt
  2. wn.provide("wn.ui.form")
  3. wn.ui.form.LinkedWith = Class.extend({
  4. init: function(opts) {
  5. var me = this;
  6. $.extend(this, opts);
  7. },
  8. show: function() {
  9. if(!this.dialog)
  10. this.make_dialog();
  11. this.dialog.show();
  12. this.dialog.get_input("list_by").change();
  13. },
  14. make_dialog: function() {
  15. var me = this;
  16. this.linked_with = this.frm.meta.__linked_with;
  17. var links = [];
  18. $.each(this.linked_with, function(doctype, tmp) {
  19. if(wn.model.can_get_report(doctype)) {
  20. links.push({label: wn._(doctype), value: doctype});
  21. }
  22. });
  23. links = wn.utils.sort(links, "label");
  24. this.dialog = new wn.ui.Dialog({
  25. width: 700,
  26. hide_on_page_refresh: true,
  27. title: wn._("Linked With"),
  28. fields: [
  29. { fieldtype: "HTML", label: "help",
  30. options:"<div class='help'>" + wn._("List of records in which this document is linked")
  31. +"</div>" },
  32. { fieldtype: "Select", options: links,
  33. label: wn._("Type"), fieldname: "list_by" },
  34. { fieldtype: "HTML", label: "hr", options:"<hr>" },
  35. { fieldtype: "HTML", label: "list" }
  36. ]
  37. });
  38. this.dialog.get_input("list_by").val(links[0].value);
  39. if(!links) {
  40. this.dialog.fields_dict.list.$wrapper.html("<div class='alert'>"
  41. + this.frm.doctype + ": "
  42. + (this.linked_with ? wn._("Not Linked to any record.") : wn._("Not enough permission to see links."))
  43. + "</div>")
  44. this.dialog.fields_dict.list_by.$wrapper.toggle(false);
  45. this.dialog.fields_dict.help.$wrapper.toggle(false);
  46. return;
  47. }
  48. this.dialog.get_input("list_by").change(function() {
  49. me.doctype = me.dialog.get_input("list_by").val();
  50. wn.model.with_doctype(me.doctype, function(r) {
  51. me.make_listing();
  52. me.lst.run();
  53. })
  54. });
  55. },
  56. make_listing: function() {
  57. var me = this;
  58. this.listview = wn.views.get_listview(this.doctype, this);
  59. this.lst = new wn.ui.Listing({
  60. hide_refresh: true,
  61. no_loading: true,
  62. no_toolbar: true,
  63. doctype: me.doctype,
  64. show_filters: true,
  65. parent: $(this.dialog.fields_dict.list.wrapper).empty().css("min-height", "300px")
  66. .get(0),
  67. method: 'webnotes.widgets.reportview.get',
  68. type: "GET",
  69. custom_new_doc: me.listview.make_new_doc || undefined,
  70. get_args: function() {
  71. var args = {
  72. doctype: this.doctype,
  73. fields: this.listview.fields,
  74. filters: this.filter_list.get_filters(),
  75. docstatus: ['0','1'],
  76. order_by: this.listview.order_by || undefined,
  77. group_by: this.listview.group_by || undefined,
  78. }
  79. return args;
  80. },
  81. render_row: function(parent, data) {
  82. data.doctype = this.doctype;
  83. me.listview.render(parent, data, this);
  84. },
  85. get_no_result_message: function() {
  86. return repl("<div class='alert'>%(doctype)s: " + wn._("Not linked") + "</div>", {
  87. name: me.frm.doc.name,
  88. doctype: wn._(me.doctype)
  89. })
  90. }
  91. });
  92. me.lst.filter_list.show_filters(true);
  93. me.lst.filter_list.clear_filters();
  94. var link_doctype = me.linked_with[me.doctype].child_doctype || me.doctype;
  95. me.lst.set_filter(me.linked_with[me.doctype].fieldname, me.frm.doc.name, link_doctype);
  96. me.lst.listview = me.listview;
  97. }
  98. });