[design] form toolbar

This commit is contained in:
Rushabh Mehta 2014-12-23 17:55:36 +05:30 committed by Anand Doshi
parent cd9a34616f
commit 2ada07032f
33 changed files with 607 additions and 829 deletions

View file

@ -6,7 +6,7 @@ frappe.pages['modules_setup'].onload = function(wrapper) {
single_column: true
});
wrapper.appframe.set_title_right(__("Update"), function() {
wrapper.page.set_primary_action(__("Update"), function() {
frappe.modules_setup.update(this);
})

View file

@ -33,21 +33,21 @@ frappe.PermissionEngine = Class.extend({
method: "get_roles_and_doctypes",
callback: function(r) {
me.options = r.message;
me.setup_appframe();
me.setup_page();
}
});
},
setup_appframe: function() {
setup_page: function() {
var me = this;
this.doctype_select
= this.wrapper.appframe.add_select(__("Document Types"),
= this.wrapper.page.add_select(__("Document Types"),
[{value: "", label: __("Select Document Type")+"..."}].concat(this.options.doctypes))
.change(function() {
frappe.set_route("permission-manager", $(this).val());
});
this.role_select
= this.wrapper.appframe.add_select(__("Roles"),
= this.wrapper.page.add_select(__("Roles"),
[__("Select Role")+"..."].concat(this.options.roles))
.change(function() {
me.refresh();

View file

@ -64,21 +64,21 @@ frappe.UserPermissions = Class.extend({
callback: function(r) {
me.options = r.message;
me.filters.user = me.wrapper.appframe.add_field({
me.filters.user = me.wrapper.page.add_field({
fieldname: "user",
label: __("User"),
fieldtype: "Select",
options: ([__("Select User") + "..."].concat(r.message.users)).join("\n")
});
me.filters.doctype = me.wrapper.appframe.add_field({
me.filters.doctype = me.wrapper.page.add_field({
fieldname: "doctype",
label: __("DocType"),
fieldtype: "Select",
options: ([__("Select DocType") + "..."].concat(me.get_link_names())).join("\n")
});
me.filters.user_permission = me.wrapper.appframe.add_field({
me.filters.user_permission = me.wrapper.page.add_field({
fieldname: "user_permission",
label: __("Name"),
fieldtype: "Link",
@ -86,14 +86,14 @@ frappe.UserPermissions = Class.extend({
});
if(user_roles.indexOf("System Manager")!==-1) {
me.download = me.wrapper.appframe.add_field({
me.download = me.wrapper.page.add_field({
fieldname: "download",
label: __("Download"),
fieldtype: "Button",
icon: "icon-download"
});
me.upload = me.wrapper.appframe.add_field({
me.upload = me.wrapper.page.add_field({
fieldname: "upload",
label: __("Upload"),
fieldtype: "Button",

View file

@ -40,10 +40,10 @@ frappe.ui.form.on("Customize Form", "doc_type", function(frm) {
frappe.ui.form.on("Customize Form", "refresh", function(frm) {
frm.disable_save();
frm.frm_head.appframe.iconbar.clear("1");
frm.frm_head.page.iconbar.clear("1");
if(frm.doc.doc_type) {
frm.appframe.set_title_right(__("Update"), function() {
frm.page.set_primary_action(__("Update"), function() {
if(frm.doc.doc_type) {
return frm.call({
doc: frm.doc,
@ -67,7 +67,7 @@ frappe.ui.form.on("Customize Form", "refresh", function(frm) {
}
// if(!frm.doc.doc_type) {
// var frm_head = frm.frm_head.appframe;
// var frm_head = frm.frm_head.page;
// $(frm_head.buttons['Update']).prop('disabled', true);
// $(frm_head.buttons['Refresh Form']).prop('disabled', true);
// $(frm_head.buttons['Reset to defaults']).prop('disabled', true);

View file

@ -11,7 +11,7 @@ frappe.pages['activity'].onload = function(wrapper) {
var list = new frappe.ui.Listing({
hide_refresh: true,
appframe: wrapper.appframe,
page: wrapper.page,
method: 'frappe.desk.page.activity.activity.get_feed',
parent: $(wrapper).find(".layout-main"),
render_row: function(row, data) {
@ -20,11 +20,11 @@ frappe.pages['activity'].onload = function(wrapper) {
});
list.run();
wrapper.appframe.set_title_right(__("Refresh"), function() { list.run(); });
wrapper.page.set_primary_action(__("Refresh"), function() { list.run(); });
// Build Report Button
if(frappe.boot.user.can_get_report.indexOf("Feed")!=-1) {
wrapper.appframe.add_button(__('Build Report'), function() {
wrapper.page.add_button(__('Build Report'), function() {
frappe.set_route('Report', "Feed");
}, 'icon-th');
}

View file

@ -15,7 +15,6 @@
"public/js/lib/moment/moment.min.js",
"public/js/lib/highlight.pack.js",
"website/js/website.js",
"website/js/website_group.js"
],
"js/canvasResize.min.js": [
"website/js/jquery.exif.js",
@ -37,7 +36,6 @@
"public/css/font-awesome.css",
"public/css/octicons/octicons.css",
"public/css/desk.css",
"public/css/appframe.css",
"public/css/app_icon.css",
"public/css/avatar.css",
"public/css/navbar.css",
@ -80,8 +78,8 @@
"public/js/legacy/handler.js",
"public/js/legacy/loaders.js",
"public/js/frappe/ui/appframe.html",
"public/js/frappe/ui/appframe.js",
"public/js/frappe/ui/page.html",
"public/js/frappe/ui/page.js",
"public/js/frappe/ui/iconbar.js",
"public/js/frappe/form/layout.js",
"public/js/frappe/ui/field_group.js",

View file

@ -1,198 +0,0 @@
/* appframe header */
.appframe {
/* padding-top: 15px;
padding-bottom: 15px;*/
}
.appframe-wrapper {
background-color: #fff;
/*box-shadow: 1px 0px 1px rgba(0,0,0,0.4);*/
}
.appframe-titlebar {
border-bottom: 1px solid #d1d8dd;
padding-top: 10px;
padding-bottom: 10px;
}
/*.appframe-titlebar, .appframe-iconbar, .appframe-form, .appframe-primary-actions {
background-color: #f9f9f9;
}*/
.appframe-primary-actions {
border-bottom: 1px solid #d1d8dd;
}
.appframe-primary-actions .btn {
margin: 10px;
margin-left: 0px;
}
.appframe-iconbar {
border-bottom: 1px solid #d1d8dd;
}
.titlebar-item h3 {
display: inline-block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding: 7px 0px;
margin: 0px;
}
.titlebar-item.text-right {
margin-top: 3px;
}
.titlebar-left-item {
float: left;
width: 30px;
}
h2.titlebar-left-item {
margin-top: -2px !important;
}
.titlebar-center-item {
float: left;
width: 90%;
}
.title-sub {
font-size: 50%;
color: #888;
margin-top: 4px;
}
@media (max-width: 768px) {
.titlebar-center-item {
width: 80%;
}
.titlebar-item h2 {
font-size: 20px;
}
}
.appframe-header {
margin-bottom: 20px;
}
.appframe-toolbar {
margin-bottom: 0px;
}
.appframe-header .status-bar {
text-align: right;
}
/* fixed navbar in appframe */
.appframe .navbar {
margin-left: -15px;
margin-right: -15px;
margin-bottom: 0px;
border-radius: 0px;
border-bottom: 1px solid #e7e7e7;
min-height: 51px;
}
.appframe .navbar-form select,
.appframe .navbar-form input,
.appframe .navbar-form button,
.appframe .navbar-form label {
margin-bottom: 5px;
}
.appframe .navbar-form {
margin-bottom: 2px;
width: 100%;
}
.appframe-iconbar, .appframe-form {
/*border-bottom: 1px solid #d1d8dd;*/
}
.appframe-form {
padding: 2px 0px 5px 0px;
}
.appframe-form input, .appframe-form select, .appframe-form label {
font-size: 90%;
padding: 4px;
margin: 3px 0px;
}
.appframe-form .form-group {
margin-bottom: 0px;
}
.appframe-form .form-control {
height: 28px;
margin-top: 0px;
}
.iconbar {
display: inline-block;
padding: 9px 0px;
}
.iconbar-4 {
border-left: 1px solid #d1d8dd;
padding-left: 4px;
}
.iconbar ul {
list-style: none;
margin: 0 0 0 0;
padding: 0 0 0 0;
}
.iconbar li {
display: inline-block;
padding-left: 4px;
padding-right: 4px;
}
.iconbar i {
margin-top: 4px;
margin-right: 4px;
color: #888;
cursor: pointer;
font-size: 16px;
}
.iconbar i:hover {
color: #000;
}
.iconbar i:active {
color: #5bc0de;
}
.iconbar .appframe-iconbar-active i {
font-weight: bold;
color: orange;
}
.workflow-button-area {
margin-bottom: 15px;
}
.appframe-control-label {
font-size: 75% !important;
margin: 0px auto !important;
padding: 0px 4px !important;
}
.appframe-only-label {
margin-top: 21px !important;
text-align: center;
}
.appframe-form .checkbox {
margin-top: 15px !important;
margin-bottom: -7px !important;
}

File diff suppressed because one or more lines are too long

View file

@ -67,9 +67,22 @@ em.link-option {
}
}
.app-page {
padding: 0px;
overflow: hidden;
/* page */
.page-head {
border-bottom:1px solid #d8dfe6;
height:72px;
}
.page-actions {
padding-top: 20px;
}
/* show menu aligned to the right border of the dropdown */
.page-actions .dropdown-menu {
right: 0px;
left: auto;
font-size: 12px;
}
.layout-main-section {
@ -77,9 +90,38 @@ em.link-option {
border-top: 0px;
}
/*.limit-container-width .container {
max-width: 970px;
}*/
.indicator {
background:none;
font-size:12px;
vertical-align:middle;
font-weight:bold;
color:#6c7680;
}
.indicator::before {
margin:0 4px 0 8px;
content:'';
display:inline-block;
height:8px;
width:8px;
border-radius:8px;
}
.indicator.grey::before {
background:#f0f4f7;
}
.indicator.blue::before {
background:#5e64ff;
}
.indicator.red::before {
background:#ff5858;
}
.indicator.green::before {
background:#98d85b;
}
.indicator.orange::before {
background:#ffa00a;
}
/* listing */
@ -106,6 +148,10 @@ em.link-option {
border-bottom: 1px solid #d1d8dd;
}
.list-row:hover, .grid-row:hover {
background:#f7fafc;
}
.list-row:last-child {
border-bottom: 0px;
}
@ -337,7 +383,7 @@ em.link-option {
.timeline {
border: 1px solid #d1d8dd;
margin: 30px -15px;
margin: 30px 0px;
}
.timeline-item {

View file

@ -10,17 +10,6 @@ frappe.ui.form.make_control = function (opts) {
}
}
// old style
function make_field(docfield, doctype, parent, frm, in_grid, hide_label) { // Factory
return frappe.ui.form.make_control({
df: docfield,
doctype: doctype,
parent: parent,
only_input: hide_label,
frm: frm
});
}
frappe.ui.form.Control = Class.extend({
init: function(opts) {
$.extend(this, opts);

View file

@ -61,7 +61,7 @@ frappe.ui.form.AssignTo = Class.extend({
.appendTo(this.$list);
if(d[i].owner===user) {
me.primary_action = this.frm.appframe.add_primary_action(__("Assignment Complete"), function() {
me.primary_action = this.frm.page.add_menu_item(__("Assignment Complete"), function() {
me.remove(user);
}, "icon-ok", "btn-success")
}

View file

@ -4,18 +4,6 @@
<div class="sidebar-section">
<h5>{%= __("Comments") %}
<span class="label label-default n-comments"></span></h5>
</div>
<div class="sidebar-section">
<ul class="standard-actions list-unstyled">
<li data-perm="{%= doctype %}::allow_print">
<a onclick="cur_frm.print_doc()">{%= __("Print") %}</a></li>
<li>
<a onclick="cur_frm.copy_doc()">{%= __("Duplicate") %}</a></li>
<li>
<a onclick="cur_frm.toolbar.show_linked_with()">{%= __("Links") %}</a></li>
<li class="system-manager">
<a onclick="cur_frm.show_settings()">{%= __("Settings") %}</a></li>
</ul>
</div>
<div class="sidebar-section form-tags">
<h5 style="display: inline-block">

View file

@ -10,12 +10,12 @@ frappe.ui.form.InfoBar = Class.extend({
make: function() {
var me = this;
this.appframe.iconbar.clear(2);
this.$reload = this.appframe.add_icon_btn("2", "icon-refresh", __("Reload Page"),
this.page.iconbar.clear(2);
this.$reload = this.page.add_icon_btn("2", "icon-refresh", __("Reload Page"),
function() { me.frm.reload_doc(); })
this.$timestamp = this.appframe.add_icon_btn("2", "icon-user", __("Creation / Modified By"),
this.$timestamp = this.page.add_icon_btn("2", "icon-user", __("Creation / Modified By"),
function() {
msgprint("Created By: " + frappe.user.full_name(me.frm.doc.owner) + "<br>" +
"Created On: " + comment_when(me.frm.doc.creation) + "<br>" +
@ -23,29 +23,29 @@ frappe.ui.form.InfoBar = Class.extend({
"Last Modifed On: " + comment_when(me.frm.doc.modified))
});
this.$comments = this.appframe.add_icon_btn("2", "icon-comments", __("Comments"), function() {
this.$comments = this.page.add_icon_btn("2", "icon-comments", __("Comments"), function() {
me.scroll_to(".form-comments .btn-go");
});
this.$attachments = this.appframe.add_icon_btn("2", "icon-paper-clip", __("Attachments"), function() {
this.$attachments = this.page.add_icon_btn("2", "icon-paper-clip", __("Attachments"), function() {
me.scroll_to(".form-attachments");
});
this.$assignments = this.appframe.add_icon_btn("2", "icon-flag", __("Assignments"), function() {
this.$assignments = this.page.add_icon_btn("2", "icon-flag", __("Assignments"), function() {
me.scroll_to(".form-assignments");
});
this.$links = this.appframe.add_icon_btn("2", "icon-link", __("Linked With"),
this.$links = this.page.add_icon_btn("2", "icon-link", __("Linked With"),
function() { me.frm.toolbar.show_linked_with(); });
this.$star = this.appframe.add_icon_btn("2", "icon-star star-action", __("Star this document"),
this.$star = this.page.add_icon_btn("2", "icon-star star-action", __("Star this document"),
function() {
frappe.ui.toggle_star(me.$star, me.frm.doctype,
me.frm.doc.name) }).find(".star-action");
// link to user permissions
if(!me.frm.meta.issingle && frappe.model.can_set_user_permissions(me.frm.doctype, me.frm)) {
this.$user_properties = this.appframe.add_icon_btn("2", "icon-shield",
this.$user_properties = this.page.add_icon_btn("2", "icon-shield",
__("User Permissions Manager"), function() {
frappe.route_options = {
doctype: me.frm.doctype,
@ -56,20 +56,20 @@ frappe.ui.form.InfoBar = Class.extend({
}
if(frappe.model.can_print(me.frm.doctype, me.frm)) {
this.$print = this.appframe.add_icon_btn("2", "icon-print", __("Print"),
this.$print = this.page.add_icon_btn("2", "icon-print", __("Print"),
function() { me.frm.print_doc(); });
}
if(frappe.model.can_email(me.frm.doctype, me.frm)) {
this.$print = this.appframe.add_icon_btn("2", "icon-envelope", __("Email"),
this.$print = this.page.add_icon_btn("2", "icon-envelope", __("Email"),
function() { me.frm.email_doc(); });
}
if(!this.frm.meta.issingle) {
this.$prev = this.appframe.add_icon_btn("2", "icon-arrow-left", __("Previous Record"),
this.$prev = this.page.add_icon_btn("2", "icon-arrow-left", __("Previous Record"),
function() { me.go_prev_next(true); });
this.$next = this.appframe.add_icon_btn("2", "icon-arrow-right", __("Next Record"),
this.$next = this.page.add_icon_btn("2", "icon-arrow-right", __("Next Record"),
function() { me.go_prev_next(false); });
}
@ -107,9 +107,9 @@ frappe.ui.form.InfoBar = Class.extend({
$.each(["comments", "attachments", "assignments"], function(i, v) {
if(me.docinfo[v] && me.docinfo[v].length)
me["$" + v].addClass("appframe-iconbar-active");
me["$" + v].addClass("page-toolbar-active");
else
me["$" + v].removeClass("appframe-iconbar-active");
me["$" + v].removeClass("page-toolbar-active");
});
// toggle star icon

View file

@ -103,7 +103,14 @@ frappe.ui.form.Layout = Class.extend({
make_field: function(df, colspan) {
!this.section && this.make_section();
!this.column && this.make_column();
var fieldobj = make_field(df, this.doctype, this.column.get(0), this.frm);
var fieldobj = frappe.ui.form.make_control({
df: df,
doctype: this.doctype,
parent: this.column.get(0),
frm: this.frm
});
fieldobj.layout = this;
this.fields_list.push(fieldobj);
this.fields_dict[df.fieldname] = fieldobj;

View file

@ -7,7 +7,7 @@ frappe.ui.form.PrintPreview = Class.extend({
this.bind_events();
},
make: function() {
this.wrapper = this.frm.appframe.add_view("print", frappe.render_template("print_layout", {}));
this.wrapper = this.frm.page.add_view("print", frappe.render_template("print_layout", {}));
},
bind_events: function() {
var me = this;

View file

@ -5,62 +5,40 @@ frappe.provide("frappe.ui.form");
frappe.ui.form.Toolbar = Class.extend({
init: function(opts) {
$.extend(this, opts);
this.make();
this.make_menu();
this.refresh();
this.add_update_button_on_dirty();
frappe.add_breadcrumbs(this.frm.meta.module, this.frm.doctype)
},
make: function() {
this.set_title();
this.frm.sidebar.clear_user_actions();
this.show_title_as_dirty();
return;
if(this.frm.meta.hide_toolbar) {
this.appframe.set_title_right();
this.frm.save_disabled = true;
this.appframe.iconbar.hide();
} else {
this.appframe.iconbar.clear(1);
this.appframe.iconbar.clear(4);
this.make_file_menu();
this.make_cancel_amend_button();
this.set_title_right();
this.show_infobar();
if(this.frm.doc.__islocal) {
this.appframe.iconbar.hide(2);
this.appframe.iconbar.hide(3);
} else {
this.appframe.iconbar.show(2);
this.appframe.iconbar.show(3);
}
}
},
refresh: function() {
this.make();
this.set_title();
this.page.clear_user_actions();
this.show_title_as_dirty();
this.set_primary_action();
if(this.frm.meta.hide_toolbar) {
this.page.hide_menu();
} else {
if(this.frm.doc.__islocal) {
this.page.hide_menu();
} else {
this.page.show_menu();
}
}
},
set_title: function() {
if(this.frm.meta.title_field) {
var title = (this.frm.doc[this.frm.meta.title_field] || "").trim() || __(this.frm.docname);
if(this.frm.doc.__islocal || title === this.frm.docname) {
this.appframe.set_title_sub("");
this.page.set_title_sub("");
} else {
this.appframe.set_title_sub("#" + this.frm.docname);
this.page.set_title_sub("#" + this.frm.docname);
}
} else {
var title = __(this.frm.docname);
}
var me = this;
this.appframe.set_title(title + this.get_lock_status());
if(this.frm.meta.issingle) {
this.appframe.set_title_left(function() { frappe.set_route(frappe.get_module(me.frm.meta.module).link); });
} else {
this.appframe.set_title_left(function() {
me.frm.list_route
? frappe.set_route(me.frm.list_route)
: frappe.set_route("List", me.frm.doctype);
});
}
this.page.set_title(title);
this.set_indicator();
},
show_infobar: function() {
/* docs:
@ -70,99 +48,73 @@ frappe.ui.form.Toolbar = Class.extend({
if(this.infobar)
this.infobar.refresh();
else
this.infobar = new frappe.ui.form.InfoBar({appframe:this.appframe, frm:this.frm});
this.infobar = new frappe.ui.form.InfoBar({page:this.page, frm:this.frm});
},
get_dropdown_menu: function(label) {
return this.appframe.add_dropdown(label);
return this.page.add_dropdown(label);
},
get_lock_status: function() {
set_indicator: function() {
if(this.frm.meta.is_submittable && !this.frm.doc.__islocal) {
switch(this.frm.doc.docstatus) {
case 0:
return ' <i class="icon-unlock text-muted" title="' +__("Not Submitted") + '">';
return this.page.set_indicator(__("Draft"), "blue");
case 1:
return ' <i class="icon-lock" title="' +__("Submitted") + '">';
return this.page.set_indicator(__("Submitted"), "blue");
case 2:
return ' <i class="icon-ban-circle text-danger" title="' +__("Cancelled") + '">';
return this.page.set_indicator(__("Cancelled"), "red");
}
} else {
return "";
this.page.clear_indicator();
}
},
make_file_menu: function() {
make_menu: function() {
var me = this;
var p = this.frm.perm[0];
var docstatus = cint(this.frm.doc.docstatus);
$(".custom-menu").remove();
// New
if(p[CREATE]) {
this.appframe.add_dropdown_button("File", __("New") + " "
+ __(me.frm.doctype), function() {
new_doc(me.frm.doctype);}, 'icon-plus');
}
// Save
if(docstatus==0 && p[WRITE] && !this.read_only) {
this.appframe.add_dropdown_button("File", __("Save"), function() {
me.frm.save('Save', null, this);}, 'icon-save');
}
// Submit
if(docstatus==0 && !this.frm.doc.__unsaved && p[SUBMIT] && !this.read_only) {
this.appframe.add_dropdown_button("File", __("Submit"), function() {
me.frm.savesubmit(this);}, 'icon-lock');
}
// Cancel
if(this.can_cancel()) {
this.appframe.add_dropdown_button("File", __("Cancel"), function() {
me.frm.savecancel(this);}, 'icon-ban-circle');
}
// Amend
if(this.can_amend()) {
this.appframe.add_dropdown_button("File", __("Amend"), function() {
me.frm.amend_doc();}, 'icon-pencil');
}
// Print
if(!me.frm.doc.__islocal && frappe.model.can_print(null, me.frm)) {
this.appframe.add_dropdown_button("File", __("Print..."), function() {
me.frm.print_doc();}, 'icon-print');
this.page.add_menu_item(__("Print"), function() {
me.frm.print_doc();}, true);
}
// email
if(!me.frm.doc.__islocal && frappe.model.can_email(null, me.frm)) {
this.appframe.add_dropdown_button("File", __("Email..."), function() {
me.frm.email_doc();}, 'icon-envelope');
this.page.add_menu_item(__("Email"), function() {
me.frm.email_doc();}, true);
}
// Linked With
if(!me.frm.doc.__islocal && !me.frm.meta.issingle) {
this.appframe.add_dropdown_button("File", __('Linked With'), function() {
this.page.add_menu_item(__('Links'), function() {
me.show_linked_with();
}, "icon-link")
}, true)
}
// copy
if(in_list(frappe.boot.user.can_create, me.frm.doctype) && !me.frm.meta.allow_copy) {
this.appframe.add_dropdown_button("File", __("Copy"), function() {
me.frm.copy_doc();}, 'icon-copy');
this.page.add_menu_item(__("Duplicate"), function() {
me.frm.copy_doc();}, true);
}
// rename
if(me.frm.meta.allow_rename && me.frm.perm[0].write) {
this.appframe.add_dropdown_button("File", __("Rename..."), function() {
me.frm.rename_doc();}, 'icon-retweet');
this.page.add_menu_item(__("Rename..."), function() {
me.frm.rename_doc();}, true);
}
// delete
if((cint(me.frm.doc.docstatus) != 1) && !me.frm.doc.__islocal
&& frappe.model.can_delete(me.frm.doctype)) {
this.appframe.add_dropdown_button("File", __("Delete"), function() {
me.frm.savetrash();}, 'icon-trash');
this.page.add_menu_item(__("Delete"), function() {
me.frm.savetrash();}, true);
}
// New
if(p[CREATE]) {
this.page.add_menu_item(__("New") + " "
+ __(me.frm.doctype), function() {
new_doc(me.frm.doctype);}, true);
}
},
@ -209,14 +161,13 @@ frappe.ui.form.Toolbar = Class.extend({
}
this.frm.linked_with.show();
},
set_title_right: function(dirty) {
set_primary_action: function(dirty) {
var me = this,
current = this.appframe.get_title_right_text(),
status = null;
if (!dirty) {
// don't clear actions menu if dirty
this.frm.sidebar.clear_user_actions();
this.page.clear_user_actions();
}
if (this.can_submit()) {
@ -234,32 +185,39 @@ frappe.ui.form.Toolbar = Class.extend({
}
if (status) {
if (status !== current) {
if (status !== this.current_status) {
this.page.clear_actions();
var perm_to_check = this.frm.action_perm_type_map[status];
if(!this.frm.perm[0][perm_to_check]) {
return;
}
this.appframe.set_title_right(__(status), {
"Save": function() {
me.frm.save('Save', null, this);
},
"Submit": function() {
me.frm.savesubmit(this);
},
"Update": function() {
me.frm.save('Update', null, this);
},
"Cancel": function() {
if(status == "Cancel") {
this.page.set_secondary_action(__(status), function() {
me.frm.savecancel(this);
},
"Amend": function() {
me.frm.amend_doc();
}
}[status], null, status === "Cancel" ? "btn-default" : "btn-primary");
});
} else {
this.page.set_primary_action(__(status), {
"Save": function() {
me.frm.save('Save', null, this);
},
"Submit": function() {
me.frm.savesubmit(this);
},
"Update": function() {
me.frm.save('Update', null, this);
},
"Amend": function() {
me.frm.amend_doc();
}
}[status]);
}
this.current_status = status;
}
} else {
this.appframe.set_title_right();
this.page.clear_actions();
}
},
make_cancel_amend_button: function() {
@ -271,10 +229,10 @@ frappe.ui.form.Toolbar = Class.extend({
if(has_workflow) {
return;
} else if(docstatus==1 && p[CANCEL]) {
this.appframe.add_button('Cancel', function() {
this.page.set_secondary_action('Cancel', function() {
me.frm.savecancel(this) }, 'icon-ban-circle');
} else if(docstatus==2 && p[AMEND]) {
this.appframe.add_button('Amend', function() {
this.page.set_secondary_action('Amend', function() {
me.frm.amend_doc() }, 'icon-pencil', true);
}
},
@ -288,13 +246,10 @@ frappe.ui.form.Toolbar = Class.extend({
if(this.frm.save_disabled)
return;
this.appframe.get_title_area()
.toggleClass("text-warning", this.frm.doc.__unsaved ? true : false)
if(this.frm.doc.__unsaved) {
this.page.set_indicator(__("Not Saved"), "orange")
}
this.set_title();
this.set_title_right(true);
// set state in wrapper
$(this.frm.wrapper).attr("data-state", this.frm.doc.__unsaved ? "dirty" : "clean");
}
})

View file

@ -19,7 +19,7 @@ frappe.ui.form.States = Class.extend({
},
make: function() {
this.parent = this.frm.appframe.parent
this.parent = this.frm.page.parent
.find(".workflow-button-area")
.empty()
.removeClass("hide");

View file

@ -15,7 +15,7 @@ frappe.views.ListFactory = frappe.views.Factory.extend({
} else {
new frappe.views.DocListView({
doctype: doctype,
page: me.make_page(true)
parent: me.make_page(true)
});
me.set_cur_list();
}
@ -50,7 +50,7 @@ frappe.views.DocListView = frappe.ui.Listing.extend({
this.setup();
var me = this;
$(this.page).on("show", function() {
$(this.parent).on("show", function() {
me.refresh();
});
@ -60,8 +60,8 @@ frappe.views.DocListView = frappe.ui.Listing.extend({
make_page: function() {
var me = this;
this.page.doclistview = this;
this.$page = $(this.page).css({"min-height": "400px"});
this.parent.doclistview = this;
this.$page = $(this.parent).css({"min-height": "400px"});
$('<div class="frappe-list-area">\
<div class="help">'+__('Loading')+'...</div></div>')
@ -69,15 +69,11 @@ frappe.views.DocListView = frappe.ui.Listing.extend({
this.$page.find(".layout-main-section")
.addClass("listview-main-section");
this.appframe = this.page.appframe;
this.page = this.parent.page;
var module = locals.DocType[this.doctype].module;
this.appframe.set_title(__("{0} List", [__(this.doctype)]));
this.page.set_title(__("{0} List", [__(this.doctype)]));
frappe.add_breadcrumbs(module);
this.appframe.set_title_left(function() {
frappe.set_route(frappe.listview_parent_route[me.doctype]
|| frappe.get_module(module).link);
});
},
setup: function() {
@ -100,14 +96,6 @@ frappe.views.DocListView = frappe.ui.Listing.extend({
if(this.listview.settings.onload) {
this.listview.settings.onload(this);
}
if(this.listview.settings.set_title_left) {
this.appframe.set_title_left(this.listview.settings.set_title_left);
} else if(this.listview.settings.parent_route) {
this.appframe.set_title_left(function() {
frappe.set_route(me.listview.settings.parent_route);
});
}
},
set_sidebar_height: function() {
@ -306,22 +294,22 @@ frappe.views.DocListView = frappe.ui.Listing.extend({
return;
if(this.can_delete || this.listview.settings.selectable) {
this.appframe.add_icon_btn("2", 'icon-ok', __('Select All'), function() {
this.page.add_icon_btn("2", 'icon-ok', __('Select All'), function() {
me.$page.find('.list-delete').prop("checked",
me.$page.find('.list-delete:checked').length ? false : true);
});
this.appframe.add_icon_btn("2", 'icon-trash', __('Delete'),
this.page.add_icon_btn("2", 'icon-trash', __('Delete'),
function() { me.delete_items(); });
}
if(frappe.model.can_import(this.doctype)) {
this.appframe.add_icon_btn("2", "icon-upload", __("Import"), function() {
this.page.add_icon_btn("2", "icon-upload", __("Import"), function() {
frappe.set_route("data-import-tool", {
doctype: me.doctype
})
});
}
if(frappe.model.can_set_user_permissions(this.doctype)) {
this.appframe.add_icon_btn("2", "icon-shield",
this.page.add_icon_btn("2", "icon-shield",
__("User Permissions Manager"), function() {
frappe.route_options = {
doctype: me.doctype
@ -330,14 +318,14 @@ frappe.views.DocListView = frappe.ui.Listing.extend({
});
}
if(in_list(user_roles, "System Manager")) {
this.appframe.add_icon_btn("2", "icon-lock",
this.page.add_icon_btn("2", "icon-lock",
__("Role Permissions Manager"), function() {
frappe.route_options = {
doctype: me.doctype
};
frappe.set_route("permission-manager");
});
this.appframe.add_icon_btn("2", "icon-glass", __("Customize"), function() {
this.page.add_icon_btn("2", "icon-glass", __("Customize"), function() {
frappe.set_route("Form", "Customize Form", {
doctype: me.doctype
})

View file

@ -1,27 +0,0 @@
<div class="appframe-titlebar">
<div class="container">
<div class="row">
<div class="titlebar-item col-sm-8">
<h3 class="titlebar-left-item hide"></h2>
<h3 class="titlebar-center-item"></h2>
</div>
<div class="titlebar-item text-right col-sm-4"></div>
</div>
</div>
</div>
<div class="app-page container">
<div class="appframe-iconbar hide">
<div class="container">
</div>
</div>
<div class="appframe-form hide">
<div class="container">
</div>
</div>
<div class="appframe-wrapper">
<div class="appframe container">
<div class="workflow-button-area btn-group pull-right hide"></div>
<div class="clearfix"></div>
</div>
</div>
</div>

View file

@ -1,294 +0,0 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// MIT License. See license.txt
// __("Form")
frappe.ui.AppFrame = Class.extend({
init: function(parent, title, module) {
this.set_document_title = true;
this.buttons = {};
this.fields_dict = {};
this.parent = parent;
var $center = parent.find(".titlebar-center-item");
this.$title_area = $('<span class="title-area">\
<span class="title-icon text-muted" style="display: none"></span>\
<span class="title-text"></span>\
</span>').appendTo($center);
this.$sub_title_area = $('<div class="title-sub hide"></div>')
.appendTo($center);
this.setup_iconbar();
if(title)
this.set_title(title);
},
setup_iconbar: function() {
var me = this;
this.iconbar = new frappe.ui.IconBar(this.parent.find(".appframe-iconbar .container"), 3);
this.iconbar.$wrapper.find(".iconbar-3").addClass("pull-right");
this.iconbar.$wrapper.on("shown", function() {
me.parent.find(".appframe-iconbar").removeClass("hide")
})
this.iconbar.$wrapper.on("hidden", function() {
me.parent.find(".appframe-iconbar").addClass("hide")
})
},
// appframe::title
get_title_area: function() {
return this.$title_area;
},
set_title: function(txt) {
// strip icon
this.title = txt;
document.title = txt.replace(/<[^>]*>/g, "");
this.$title_area.find(".title-text").html(txt);
},
set_title_sub: function(txt) {
// strip icon
this.$sub_title_area.html(txt).toggleClass("hide", !!!txt);
},
set_title_left: function(click) {
return $("<a>")
.html('<i class="icon-angle-left text-muted" style="margin-right: 10px; \
font-weight: bold; text-decoration: none;"></i>')
.on("click", function() { click.apply(this); })
.appendTo(this.parent.find(".titlebar-left-item").empty());
},
set_title_right: function(txt, click, icon, btn_class) {
if(!btn_class) btn_class="btn-primary"
var $right = this.parent.find(".titlebar-item.text-right")
if(txt) {
this.title_right && this.title_right.remove();
this.title_right = $("<a class='btn btn-sm "+btn_class+"'>")
.html((icon ? '<i class="'+icon+'"></i> ' : "") + txt)
.click(click)
.appendTo($right.attr("data-text", txt));
return this.title_right;
} else {
$right.empty().attr("data-text", "");
this.title_right = null;
this.primary_dropdown = null;
this.primary_action = null;
}
},
get_title_right_text: function() {
return this.parent.find(".titlebar-item.text-right").attr("data-text");
},
add_primary_action: function(label, click, icon, toolbar_or_class) {
this.sidebar.add_user_action(label, click);
return;
if(toolbar_or_class===true) {
this.add_icon_btn("4", icon, label, click);
return;
}
var wrapper = this.parent.find(".appframe-primary-actions .container");
this.parent.find(".appframe-primary-actions").removeClass("hide");
if($.isArray(click)) {
// if onclick is an array, add a dropdown button
var $btn_group = $('<div class="btn-group">\
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">\
'+label+' <span class="caret"></span>\
</button>\
<ul class="dropdown-menu" role="menu">\
</ul>').appendTo(wrapper);
var $ul = $btn_group.find(".dropdown-menu");
$.each(click, function(i, v) {
var $a = $('<li><a>'+v.label+'</a></li>')
.appendTo($ul)
.find('a').on('click', v.click);
if(v.value) $a.attr('data-value', v.value);
});
// activate dropdown
$btn_group.find(".dropdown-toggle").dropdown();
} else {
return $(repl('<button class="btn %(klass)s btn-sm">\
<i class="%(icon)s"></i> %(label)s</button>', {label:label, icon:icon,
klass: toolbar_or_class || "btn-primary"}))
.on("click", click)
.appendTo(wrapper);
};
},
add_module_icon: function(module, doctype, onclick, sub_title) {
var module_info = frappe.get_module(module);
if(!module_info) {
module_info = {
icon: "icon-question-sign",
color: "#ddd"
}
}
var icon = frappe.boot.doctype_icons[doctype] || module_info.icon;
this.get_main_icon(icon)
.attr("doctype-name", doctype);
this.set_title_left(function() {
var route = frappe.get_route()[0]==module_info.link ? "" : module_info.link;
frappe.set_route(route);
});
},
get_main_icon: function(icon) {
return this.$title_area.find(".title-icon")
.html('<i class="'+icon+' icon-fixed-width"></i> ')
.toggle(true);
},
add_help_button: function(txt) {
this.add_icon_btn("2", "icon-question-sign", __("Help"),
function() { msgprint($(this).data('help-text'), 'Help'); })
.data("help-text", txt);
},
add_icon_btn: function(group, icon, label, click) {
return this.iconbar.add_btn(group, icon, label, click);
},
add_button: function(label, click, icon, is_title) {
return this.add_icon_btn("1", icon, __(label), click);
},
add_dropdown_button: function(parent, label, click, icon) {
frappe.ui.toolbar.add_dropdown_button(parent, label, click, icon);
},
// appframe::form
add_label: function(label) {
this.show_form();
return $("<label class='col-md-1 appframe-only-label'>"+label+" </label>")
.appendTo(this.parent.find(".appframe-form .container"));
},
add_select: function(label, options) {
var field = this.add_field({label:label, fieldtype:"Select"})
return field.$wrapper.find("select").empty().add_options(options);
},
add_data: function(label) {
var field = this.add_field({label: label, fieldtype: "Data"});
return field.$wrapper.find("input").attr("placeholder", label);
},
add_date: function(label, date) {
var field = this.add_field({label: label, fieldtype: "Date", "default": date});
return field.$wrapper.find("input").attr("placeholder", label);
},
add_check: function(label) {
return $("<div class='checkbox' style='margin-right: 10px; margin-top: 7px; float: left;'><label><input type='checkbox'>" + label + "</label></div>")
.appendTo(this.parent.find(".appframe-form .container"))
.find("input");
},
add_break: function() {
// add further fields in the next line
this.parent.find(".appframe-form .container")
.append('<div class="clearfix invisible-xs"></div>');
},
add_field: function(df) {
this.show_form();
var f = frappe.ui.form.make_control({
df: df,
parent: this.parent.find(".appframe-form .container"),
only_input: df.fieldtype=="Check" ? false : true,
})
f.refresh();
$(f.wrapper)
.addClass('col-md-2')
.css({
"padding-left": "0px",
"padding-right": "7px",
})
.attr("title", __(df.label)).tooltip();
f.$input.attr("placeholder", __(df.label));
if(df.fieldtype==="Check") {
$(f.wrapper).find(":first-child")
.removeClass("col-md-offset-4 col-md-8");
} else {
$(f.wrapper)
.prepend('<label class="appframe-control-label">' + __(df.label) + '</label>');
}
if(df.fieldtype=="Button") {
$(f.wrapper).find(".appframe-control-label").html("&nbsp;")
f.$input.addClass("btn-sm").css({"width": "100%", "margin-top": "-1px"});
}
if(df["default"])
f.set_input(df["default"])
this.fields_dict[df.fieldname || df.label] = f;
return f;
},
show_form: function() {
this.parent.find(".appframe-form").removeClass("hide");
},
views: {},
add_view: function(name, html) {
this.views[name] = $(html).appendTo($(this.parent).find(".appframe"));
if(!this.current_view) {
this.current_view = this.views[name];
} else {
this.views[name].toggle(false);
}
return this.views[name];
},
set_view: function(name) {
this.current_view && this.current_view.toggle(false);
this.views[name].toggle(true);
this.current_view = this.views[name];
}
});
// parent, title, single_column
// standard page with appframe
frappe.ui.make_app_page = function(opts) {
/* help: make a standard page layout with a toolbar and title */
/* options: [
"parent: [HTMLElement] parent element",
"single_column: [Boolean] false/true",
"title: [optional] set this title"
]
*/
var $wrapper = $(opts.parent)
$(frappe.templates.appframe).appendTo($wrapper);
var $appframe = $wrapper.find(".appframe");
opts.parent.appframe = new frappe.ui.AppFrame($wrapper);
if(opts.single_column) {
opts.parent.body = opts.parent.appframe.add_view("main", '<div class="layout-main">');
} else {
var main = opts.parent.appframe.add_view("main", '<div class="row layout-main">\
<div class="col-sm-2 layout-side-section"></div>\
<div class="col-sm-10">\
<div class="layout-main-section" style="margin: 0px -15px;"></div>\
</div>\
</div>');
opts.parent.body = main.find(".layout-main-section");
}
if(opts.set_document_title!==undefined)
opts.parent.appframe.set_document_title = opts.set_document_title;
if(opts.title)
opts.parent.appframe.set_title(opts.title);
if(opts.icon)
opts.parent.appframe.get_main_icon(opts.icon);
}

View file

@ -71,8 +71,6 @@ frappe.ui.Dialog = frappe.ui.FieldGroup.extend({
},
make_head: function() {
var me = this;
//this.appframe = new frappe.ui.AppFrame(this.wrapper);
//this.appframe.set_document_title = false;
this.set_title(this.title);
},
set_title: function(t) {

View file

@ -67,7 +67,7 @@ frappe.ui.Listing = Class.extend({
this.$w = $(this.parent).find('.frappe-list');
this.set_events();
if(this.appframe) {
if(this.page) {
this.$w.find('.list-toolbar-wrapper').toggle(false);
}
@ -76,8 +76,8 @@ frappe.ui.Listing = Class.extend({
}
},
add_button: function(label, click, icon) {
if(this.appframe) {
return this.appframe.add_button(label, click, icon)
if(this.page) {
return this.page.add_button(label, click, icon)
} else {
this.$w.find('.list-toolbar-wrapper').removeClass("hide");
$button = $('<button class="btn btn-default"></button>')

View file

@ -0,0 +1,41 @@
<div class="page-head">
<div class="container">
<div class="row">
<div class="page-title col-xs-8">
<h1>
<span class="title-text"></span>
<span class="indicator hide"></span>
</h1>
<h3 class="hide"></h3>
</div>
<div class="page-actions text-right col-xs-4">
<div class="btn-group hide">
<button type="button" class="btn btn-default btn-sm dropdown-toggle"
data-toggle="dropdown" aria-expanded="false">
{%= __("Menu") %} <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
</ul>
</div>
<button class="btn btn-secondary btn-default btn-sm hide"></button>
<button class="btn btn-primary btn-sm hide"></button>
</div>
</div>
</div>
</div>
<div class="page-body container">
<div class="page-toolbar hide">
<div class="container">
</div>
</div>
<div class="page-form hide">
<div class="container">
</div>
</div>
<div class="page-wrapper">
<div class="page-content">
<div class="workflow-button-area btn-group pull-right hide"></div>
<div class="clearfix"></div>
</div>
</div>
</div>

View file

@ -0,0 +1,291 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// MIT License. See license.txt
// __("Form")
// parent, title, single_column
// standard page with page
frappe.ui.make_app_page = function(opts) {
/* help: make a standard page layout with a toolbar and title */
/* options: [
"parent: [HTMLElement] parent element",
"single_column: [Boolean] false/true",
"title: [optional] set this title"
]
*/
opts.parent.page = new frappe.ui.Page(opts);
}
frappe.ui.Page = Class.extend({
init: function(opts) {
$.extend(this, opts);
this.set_document_title = true;
this.buttons = {};
this.fields_dict = {};
this.views = {};
this.make();
this.setup_iconbar();
},
make: function() {
this.wrapper = $(this.parent);
$(frappe.render_template("page", {})).appendTo(this.wrapper);
if(this.single_column) {
this.add_view("main", '<div class="layout-main">');
} else {
var main = this.add_view("main", '<div class="row layout-main">\
<div class="col-sm-2 layout-side-section"></div>\
<div class="col-sm-10">\
<div class="layout-main-section"></div>\
</div>\
</div>');
}
this.$title_area = this.wrapper.find("h1");
this.$sub_title_area = this.wrapper.find("h3");
if(this.set_document_title!==undefined)
this.set_document_title = this.set_document_title;
if(this.title)
this.set_title(this.title);
if(this.icon)
this.get_main_icon(this.icon);
this.page_actions = this.wrapper.find(".page-actions");
this.menu = this.page_actions.find(".dropdown-menu");
this.indicator = this.wrapper.find(".indicator");
this.btn_primary = this.page_actions.find(".btn-primary");
this.btn_secondary = this.page_actions.find(".btn-secondary");
this.menu_btn_group = this.page_actions.find(".btn-group");
},
set_indicator: function(label, color) {
this.clear_indicator().removeClass("hide").html(label).addClass(color);
},
clear_indicator: function() {
return this.indicator.removeClass().addClass("indicator hide");
},
set_primary_action: function(label, click) {
this.btn_primary.removeClass("hide").prop("disabled", false).html(label).on("click", click);
},
set_secondary_action: function(label, click) {
this.btn_secondary.removeClass("hide").prop("disabled", false).html(label).on("click", click);
},
clear_primary_action: function() {
this.btn_primary.addClass("hide");
},
clear_actions: function() {
this.btn_primary.addClass("hide").unbind("click");
this.btn_secondary.addClass("hide").unbind("click");
},
add_menu_item: function(label, click, standard) {
this.show_menu();
var $link = $('<li><a class="grey-link">'+ label +'</a><li>');
$link.find("a").on("click", click);
if(standard) {
$link.appendTo(this.menu);
} else {
this.divider = this.menu.find(".divider");
if(!this.divider.length) {
this.divider = $('<li class="divider user-action"></li>').prependTo(this.menu);
}
$link.addClass("user-action").insertBefore(this.divider);
}
return $link;
},
add_divider: function() {
return $('<li class="divider"></li>').appendTo(this.menu);
},
hide_menu: function() {
this.menu_btn_group.addClass("hide");
},
show_menu: function() {
this.menu_btn_group.removeClass("hide");
},
clear_menu: function() {
this.menu.empty();
this.hide_menu();
},
clear_user_actions: function() {
this.menu.find(".user-action").remove();
},
setup_iconbar: function() {
var me = this;
this.iconbar = new frappe.ui.IconBar(this.wrapper.find(".page-toolbar .container"), 3);
this.iconbar.$wrapper.find(".iconbar-3").addClass("pull-right");
this.iconbar.$wrapper.on("shown", function() {
me.wrapper.find(".page-toolbar").removeClass("hide")
})
this.iconbar.$wrapper.on("hidden", function() {
me.wrapper.find(".page-toolbar").addClass("hide")
})
},
// page::title
get_title_area: function() {
return this.$title_area;
},
set_title: function(txt) {
// strip icon
this.title = txt;
document.title = txt.replace(/<[^>]*>/g, "");
this.$title_area.find(".title-text").html(txt);
},
set_title_sub: function(txt) {
// strip icon
this.$sub_title_area.html(txt).toggleClass("hide", !!!txt);
},
add_module_icon: function(module, doctype, onclick, sub_title) {
var module_info = frappe.get_module(module);
if(!module_info) {
module_info = {
icon: "icon-question-sign",
color: "#ddd"
}
}
var icon = frappe.boot.doctype_icons[doctype] || module_info.icon;
this.get_main_icon(icon)
.attr("doctype-name", doctype);
this.set_title_left(function() {
var route = frappe.get_route()[0]==module_info.link ? "" : module_info.link;
frappe.set_route(route);
});
},
get_main_icon: function(icon) {
return this.$title_area.find(".title-icon")
.html('<i class="'+icon+' icon-fixed-width"></i> ')
.toggle(true);
},
add_help_button: function(txt) {
this.add_icon_btn("2", "icon-question-sign", __("Help"),
function() { msgprint($(this).data('help-text'), 'Help'); })
.data("help-text", txt);
},
add_icon_btn: function(group, icon, label, click) {
return this.iconbar.add_btn(group, icon, label, click);
},
add_button: function(label, click, icon, is_title) {
return this.add_icon_btn("1", icon, __(label), click);
},
add_dropdown_button: function(parent, label, click, icon) {
frappe.ui.toolbar.add_dropdown_button(parent, label, click, icon);
},
// page::form
add_label: function(label) {
this.show_form();
return $("<label class='col-md-1 page-only-label'>"+label+" </label>")
.appendTo(this.wrapper.find(".page-form .container"));
},
add_select: function(label, options) {
var field = this.add_field({label:label, fieldtype:"Select"})
return field.$wrapper.find("select").empty().add_options(options);
},
add_data: function(label) {
var field = this.add_field({label: label, fieldtype: "Data"});
return field.$wrapper.find("input").attr("placeholder", label);
},
add_date: function(label, date) {
var field = this.add_field({label: label, fieldtype: "Date", "default": date});
return field.$wrapper.find("input").attr("placeholder", label);
},
add_check: function(label) {
return $("<div class='checkbox' style='margin-right: 10px; margin-top: 7px; float: left;'><label><input type='checkbox'>" + label + "</label></div>")
.appendTo(this.wrapper.find(".page-form .container"))
.find("input");
},
add_break: function() {
// add further fields in the next line
this.wrapper.find(".page-form .container")
.append('<div class="clearfix invisible-xs"></div>');
},
add_field: function(df) {
this.show_form();
var f = frappe.ui.form.make_control({
df: df,
parent: this.wrapper.find(".page-form .container"),
only_input: df.fieldtype=="Check" ? false : true,
})
f.refresh();
$(f.wrapper)
.addClass('col-md-2')
.css({
"padding-left": "0px",
"padding-right": "7px",
})
.attr("title", __(df.label)).tooltip();
f.$input.attr("placeholder", __(df.label));
if(df.fieldtype==="Check") {
$(f.wrapper).find(":first-child")
.removeClass("col-md-offset-4 col-md-8");
} else {
$(f.wrapper)
.prepend('<label class="page-control-label">' + __(df.label) + '</label>');
}
if(df.fieldtype=="Button") {
$(f.wrapper).find(".page-control-label").html("&nbsp;")
f.$input.addClass("btn-sm").css({"width": "100%", "margin-top": "-1px"});
}
if(df["default"])
f.set_input(df["default"])
this.fields_dict[df.fieldname || df.label] = f;
return f;
},
show_form: function() {
this.wrapper.find(".page-form").removeClass("hide");
},
add_view: function(name, html) {
this.views[name] = $(html).appendTo($(this.wrapper).find(".page-content"));
if(!this.current_view) {
this.current_view = this.views[name];
} else {
this.views[name].toggle(false);
}
return this.views[name];
},
set_view: function(name) {
this.current_view && this.current_view.toggle(false);
this.current_view = this.views[name];
this.views[name].toggle(true);
}
});

View file

@ -8,10 +8,10 @@
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Home</a>
</div>
<div class="collapse navbar-collapse navbar-responsive-collapse">
<ul class="nav navbar-nav navbar-left" id="navbar-breadcrumbs">
</ul>
</div>
<div class="collapse navbar-collapse navbar-responsive-collapse">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#"

View file

@ -10,7 +10,7 @@ frappe.views.CalendarFactory = frappe.views.Factory.extend({
frappe.model.with_doctype(route[1], function() {
var options = {
doctype: route[1],
page: me.make_page()
parent: me.make_page()
};
$.extend(options, frappe.views.calendar[route[1]] || {});
@ -33,21 +33,21 @@ frappe.views.Calendar = Class.extend({
},
make_page: function() {
var module = locals.DocType[this.doctype].module;
this.page.appframe.set_title(__("Calendar") + " - " + __(this.doctype));
this.parent.page.set_title(__("Calendar") + " - " + __(this.doctype));
frappe.add_breadcrumbs(module==="Core" ? "Calendar" : module, this.doctype)
this.page.appframe.add_button("New", function() {
this.parent.page.add_button("New", function() {
var doc = frappe.model.get_new_doc(me.doctype);
frappe.set_route("Form", me.doctype, doc.name);
}, "icon-plus");
var me = this;
$(this.page).on("show", function() {
$(this.parent).on("show", function() {
me.$cal.fullCalendar("refetchEvents");
})
},
make: function() {
var me = this;
this.$wrapper = $(this.page).find(".layout-main");
this.$wrapper = $(this.parent).find(".layout-main");
this.$cal = $("<div>").appendTo(this.$wrapper);
frappe.utils.set_footnote(this, this.$wrapper, __("Select or drag across time slots to create a new event."));
//

View file

@ -14,7 +14,7 @@ frappe.views.GanttFactory = frappe.views.Factory.extend({
var options = {
doctype: route[1],
page: page
parent: page
};
$.extend(options, frappe.views.calendar[route[1]] || {});
@ -39,27 +39,27 @@ frappe.views.Gantt = Class.extend({
var module = locals.DocType[this.doctype].module,
me = this;
this.appframe = this.page.appframe;
this.appframe.set_title(__("Gantt Chart") + " - " + __(this.doctype));
this.page = this.parent.page;
this.page.set_title(__("Gantt Chart") + " - " + __(this.doctype));
frappe.add_breadcrumbs(module)
this.appframe.set_title_right(__("Refresh"),
this.page.set_primary_action(__("Refresh"),
function() { me.refresh(); }, "icon-refresh")
this.appframe.add_field({fieldtype:"Date", label:"From",
this.page.add_field({fieldtype:"Date", label:"From",
fieldname:"start", "default": frappe.datetime.month_start(), input_css: {"z-index": 3}});
this.appframe.add_field({fieldtype:"Date", label:"To",
this.page.add_field({fieldtype:"Date", label:"To",
fieldname:"end", "default": frappe.datetime.month_end(), input_css: {"z-index": 3}});
if(this.filters) {
$.each(this.filters, function(i, df) {
me.appframe.add_field(df);
me.page.add_field(df);
});
}
},
refresh: function() {
var parent = $(this.page)
var parent = $(this.parent)
.find(".layout-main")
.empty()
.css('min-height', '300px')
@ -71,8 +71,8 @@ frappe.views.Gantt = Class.extend({
type: "GET",
args: {
doctype: this.doctype,
start: this.appframe.fields_dict.start.get_parsed_value(),
end: this.appframe.fields_dict.end.get_parsed_value(),
start: this.page.fields_dict.start.get_parsed_value(),
end: this.page.fields_dict.end.get_parsed_value(),
filters: this.get_filters()
},
callback: function(r) {
@ -104,7 +104,7 @@ frappe.views.Gantt = Class.extend({
if(this.filters) {
$.each(this.filters, function(i, df) {
if(df.options===value)
me.appframe.fields_dict[df.fieldname].set_input(value);
me.page.fields_dict[df.fieldname].set_input(value);
return false;
});
}
@ -115,7 +115,7 @@ frappe.views.Gantt = Class.extend({
if(this.filters) {
$.each(this.filters, function(i, df) {
filter_vals[df.fieldname || df.label] =
me.appframe.fields_dict[df.fieldname || df.label].get_parsed_value();
me.page.fields_dict[df.fieldname || df.label].get_parsed_value();
});
}
return filter_vals;
@ -165,8 +165,8 @@ frappe.views.Gantt = Class.extend({
var me = this;
if(frappe.route_options) {
$.each(frappe.route_options, function(k, value) {
if(me.appframe.fields_dict[k]) {
me.appframe.fields_dict[k].set_input(value);
if(me.page.fields_dict[k]) {
me.page.fields_dict[k].set_input(value);
};
})
frappe.route_options = null;

View file

@ -105,7 +105,7 @@ frappe.views.GridReport = Class.extend({
$(this.page).find(".app-page").addClass("full-width");
this.wrapper = $('<div>').appendTo(this.parent);
this.appframe.parent.find(".appframe").css({"padding-top": "0px"});
this.page.parent.find(".page").css({"padding-top": "0px"});
if(this.filters) {
this.make_filters();
@ -249,24 +249,24 @@ frappe.views.GridReport = Class.extend({
v.fieldname = v.fieldname || v.label.replace(/ /g, '_').toLowerCase();
var input = null;
if(v.fieldtype=='Select') {
input = me.appframe.add_select(v.label, v.options || [v.default_value]);
input = me.page.add_select(v.label, v.options || [v.default_value]);
} else if(v.fieldtype=="Link") {
input = me.appframe.add_data(v.label);
input = me.page.add_data(v.label);
input.autocomplete({
source: v.list || [],
});
} else if(v.fieldtype==='Button' && v.label==="Refresh") {
input = me.appframe.set_title_right(v.label, null, v.icon);
input = me.page.set_primary_action(v.label, null, v.icon);
} else if(v.fieldtype==='Button') {
input = me.appframe.add_button(v.label, null, v.icon);
input = me.page.add_button(v.label, null, v.icon);
} else if(v.fieldtype==='Date') {
input = me.appframe.add_date(v.label);
input = me.page.add_date(v.label);
} else if(v.fieldtype==='Label') {
input = me.appframe.add_label(v.label);
input = me.page.add_label(v.label);
} else if(v.fieldtype==='Data') {
input = me.appframe.add_data(v.label);
input = me.page.add_data(v.label);
} else if(v.fieldtype==='Check') {
input = me.appframe.add_check(v.label);
input = me.page.add_check(v.label);
}
if(input) {
@ -372,7 +372,7 @@ frappe.views.GridReport = Class.extend({
this.plot_area = $('<div class="plot" style="margin-top: 15px; margin-bottom: 15px; display: none; \
height: 300px; width: 100%;"></div>').appendTo(this.wrapper);
this.appframe.add_button(__("Export"), function() { return me.export(); }, "icon-download");
this.page.add_button(__("Export"), function() { return me.export(); }, "icon-download");
// grid wrapper
this.grid_wrapper = $("<div style='height: 500px; border: 1px solid #aaa; \

View file

@ -76,8 +76,7 @@ frappe.views.moduleview.ModuleView = Class.extend({
single_column: true,
title: __(frappe.modules[module] && frappe.modules[module].label || module)
});
wrapper.appframe.set_title_left(function() { frappe.set_route(""); });
wrapper.appframe.set_title_right(__("Refresh"), function() {
wrapper.page.set_primary_action(__("Refresh"), function() {
me.make(wrapper, module);
});

View file

@ -110,7 +110,7 @@ frappe.show_not_permitted = function(page_name) {
frappe.show_message_page = function(page_name, title, message) {
if(!page_name) page_name = frappe.get_route_str();
var page = frappe.pages[page_name] || frappe.container.add_page(page_name);
$(page).html('<div class="appframe">\
$(page).html('<div class="page">\
<div style="margin: 50px; text-align:center;">\
<h3>'+title+'</h3><br>\
<p>'+message+'</p><br>\

View file

@ -28,7 +28,7 @@ frappe.views.QueryReport = Class.extend({
init: function(opts) {
$.extend(this, opts);
// globalify for slickgrid
this.appframe = this.parent.appframe;
this.page = this.parent.page;
this.parent.query_report = this;
this.make();
},
@ -57,10 +57,10 @@ frappe.views.QueryReport = Class.extend({
},
make_toolbar: function() {
var me = this;
this.appframe.set_title_right(__('Refresh'), function() { me.refresh(); });
this.page.set_primary_action(__('Refresh'), function() { me.refresh(); });
// Edit
var edit_btn = this.appframe.add_button(__('Edit'), function() {
var edit_btn = this.page.add_button(__('Edit'), function() {
if(!frappe.user.is_report_manager()) {
msgprint(__("You are not allowed to create / edit reports"));
return false;
@ -68,11 +68,11 @@ frappe.views.QueryReport = Class.extend({
frappe.set_route("Form", "Report", me.report_name);
}, "icon-edit");
this.appframe.add_button(__('Export'), function() { me.export_report(); },
this.page.add_button(__('Export'), function() { me.export_report(); },
"icon-download");
if(frappe.model.can_set_user_permissions("Report")) {
this.appframe.add_button(__("User Permissions"), function() {
this.page.add_button(__("User Permissions"), function() {
frappe.route_options = {
doctype: "Report",
name: me.report_name
@ -89,15 +89,12 @@ frappe.views.QueryReport = Class.extend({
if((me.report_name!=route[1]) || frappe.route_options) {
me.report_name = route[1];
this.wrapper.find(".no-report-area").toggle(false);
me.appframe.set_title(__(me.report_name));
me.page.set_title(__(me.report_name));
frappe.model.with_doc("Report", me.report_name, function() {
me.report_doc = frappe.get_doc("Report", me.report_name);
me.appframe.set_title_left(function() {
frappe.set_route(frappe.get_module(me.report_doc.module).link); });
frappe.model.with_doctype(me.report_doc.ref_doctype, function() {
if(!frappe.query_reports[me.report_name]) {
return frappe.call({
@ -106,7 +103,7 @@ frappe.views.QueryReport = Class.extend({
report_name: me.report_name
},
callback: function(r) {
me.appframe.set_title(__(me.report_name));
me.page.set_title(__(me.report_name));
frappe.dom.eval(r.message.script || "");
me.setup_filters();
me.setup_html_format(r.message.html_format);
@ -139,7 +136,7 @@ frappe.views.QueryReport = Class.extend({
}
if(html_format) {
this.$print_action = this.appframe.add_button(__('Print'), function() {
this.$print_action = this.page.add_button(__('Print'), function() {
if(!me.data) {
msgprint(__("Run the report first"));
return;
@ -171,9 +168,9 @@ frappe.views.QueryReport = Class.extend({
var me = this;
$.each(frappe.query_reports[this.report_name].filters || [], function(i, df) {
if(df.fieldtype==="Break") {
me.appframe.add_break();
me.page.add_break();
} else {
var f = me.appframe.add_field(df);
var f = me.page.add_field(df);
$(f.wrapper).addClass("filters pull-left");
me.filters.push(f);
if(df["default"]) {
@ -199,16 +196,16 @@ frappe.views.QueryReport = Class.extend({
}
});
// hide appframe form if no filters
var $filters = this.appframe.parent.find('.appframe-form .filters');
this.appframe.parent.find('.appframe-form').toggle($filters.length ? true : false);
// hide page form if no filters
var $filters = this.page.parent.find('.page-form .filters');
this.page.parent.find('.page-form').toggle($filters.length ? true : false);
this.set_route_filters()
this.set_filters_by_name();
},
clear_filters: function() {
this.filters = [];
this.appframe.parent.find('.appframe-form .filters').remove();
this.page.parent.find('.page-form .filters').remove();
},
set_route_filters: function() {
var me = this;

View file

@ -26,39 +26,38 @@ frappe.views.ReportViewPage = Class.extend({
me.make_report_view();
if(me.docname) {
frappe.model.with_doc('Report', me.docname, function(r) {
me.page.reportview.set_columns_and_filters(
me.parent.reportview.set_columns_and_filters(
JSON.parse(frappe.get_doc("Report", me.docname).json));
me.page.reportview.set_route_filters();
me.page.reportview.run();
me.parent.reportview.set_route_filters();
me.parent.reportview.run();
});
} else {
me.page.reportview.set_route_filters();
me.page.reportview.run();
me.parent.reportview.set_route_filters();
me.parent.reportview.run();
}
});
},
make_page: function() {
var me = this;
this.page = frappe.container.add_page(this.page_name);
frappe.ui.make_app_page({parent:this.page, single_column:true});
this.parent = frappe.container.add_page(this.page_name);
frappe.ui.make_app_page({parent:this.parent, single_column:true});
frappe.container.change_to(this.page_name);
$(this.page).on('show', function(){
if(me.page.reportview.set_route_filters())
me.page.reportview.run();
$(this.parent).on('show', function(){
if(me.parent.reportview.set_route_filters())
me.parent.reportview.run();
})
},
make_report_view: function() {
var module = locals.DocType[this.doctype].module;
this.page.appframe.set_title(__(this.doctype));
this.parent.page.set_title(__(this.doctype));
frappe.add_breadcrumbs(module, this.doctype)
this.page.appframe.set_title_left(function() { frappe.set_route((frappe.get_module(module) || {}).link); });
this.page.reportview = new frappe.views.ReportView({
this.parent.reportview = new frappe.views.ReportView({
doctype: this.doctype,
docname: this.docname,
page: this.page,
wrapper: $(this.page).find(".layout-main")
page: this.parent,
wrapper: $(this.parent).find(".layout-main")
});
}
});
@ -66,8 +65,8 @@ frappe.views.ReportViewPage = Class.extend({
frappe.views.ReportView = frappe.ui.Listing.extend({
init: function(opts) {
var me = this;
$(this.page).find('.layout-main').html(__('Loading Report')+'...');
$(this.page).find('.layout-main').empty();
$(this.parent).find('.layout-main').html(__('Loading Report')+'...');
$(this.parent).find('.layout-main').empty();
$.extend(this, opts);
this.can_delete = frappe.model.can_delete(me.doctype);
this.tab_name = '`tab'+this.doctype+'`';
@ -88,12 +87,12 @@ frappe.views.ReportView = frappe.ui.Listing.extend({
setup: function() {
var me = this;
this.page_title = __('Report')+ ': ' + __(this.docname ? (this.doctype + ' - ' + this.docname) : this.doctype);
this.page.appframe.set_title(this.page_title)
this.parent.page.set_title(this.page_title)
this.make({
appframe: this.page.appframe,
page: this.parent.page,
method: 'frappe.desk.reportview.get',
get_args: this.get_args,
parent: $(this.page).find('.layout-main'),
parent: $(this.parent).find('.layout-main'),
start: 0,
show_filters: true,
new_doctype: this.doctype,
@ -396,7 +395,7 @@ frappe.views.ReportView = frappe.ui.Listing.extend({
make_column_picker: function() {
var me = this;
this.column_picker = new frappe.ui.ColumnPicker(this);
this.page.appframe.add_button(__('Pick Columns'), function() {
this.parent.page.add_button(__('Pick Columns'), function() {
me.column_picker.show(me.columns);
}, 'icon-th-list');
},
@ -461,7 +460,7 @@ frappe.views.ReportView = frappe.ui.Listing.extend({
this.sort_order_next_select.val('desc');
// button actions
this.page.appframe.add_button(__('Sort By'), function() {
this.parent.page.add_button(__('Sort By'), function() {
me.sort_dialog.show();
}, 'icon-sort-by-alphabet');
@ -477,7 +476,7 @@ frappe.views.ReportView = frappe.ui.Listing.extend({
if(!frappe.model.can_export(this.doctype)) {
return;
}
var export_btn = this.page.appframe.add_button(__('Export'), function() {
var export_btn = this.parent.page.add_button(__('Export'), function() {
var args = me.get_args();
args.cmd = 'frappe.desk.reportview.export_query'
open_url_post(frappe.request.url, args);
@ -488,7 +487,7 @@ frappe.views.ReportView = frappe.ui.Listing.extend({
make_save: function() {
var me = this;
if(frappe.user.is_report_manager()) {
this.page.appframe.add_button(__('Save'), function() {
this.parent.page.add_button(__('Save'), function() {
// name
if(me.docname) {
var name = me.docname
@ -530,12 +529,12 @@ frappe.views.ReportView = frappe.ui.Listing.extend({
make_delete: function() {
var me = this;
if(this.can_delete) {
$(this.page).on("click", "input[type='checkbox'][data-row]", function() {
$(this.parent).on("click", "input[type='checkbox'][data-row]", function() {
me.data[$(this).attr("data-row")]._checked
= this.checked ? true : false;
});
this.page.appframe.add_button(__("Delete"), function() {
this.parent.page.add_button(__("Delete"), function() {
var delete_list = []
$.each(me.data, function(i, d) {
if(d._checked) {
@ -567,7 +566,7 @@ frappe.views.ReportView = frappe.ui.Listing.extend({
make_user_permissions: function() {
var me = this;
if(this.docname && frappe.model.can_set_user_permissions("Report")) {
this.page.appframe.add_button(__("User Permissions Manager"), function() {
this.parent.page.add_button(__("User Permissions Manager"), function() {
frappe.route_options = {
doctype: "Report",
name: me.docname

View file

@ -84,7 +84,7 @@ _f.Frm.prototype.setup = function() {
frappe.ui.make_app_page({
parent: this.wrapper
});
this.appframe = this.wrapper.appframe;
this.page = this.wrapper.page;
var $main_section = $(this.wrapper).find(".layout-main-section");
this.layout_main = $main_section
.css({"padding-bottom": "0px"})
@ -95,11 +95,11 @@ _f.Frm.prototype.setup = function() {
parent: $(this.wrapper).find(".layout-side-section")
});
this.appframe.sidebar = this.sidebar;
this.page.sidebar = this.sidebar;
this.toolbar = new frappe.ui.form.Toolbar({
frm: this,
appframe: this.appframe
page: this.page
});
this.frm_head = this.toolbar;
@ -178,12 +178,12 @@ _f.Frm.prototype.print_doc = function() {
.empty().add_options(this.print_preview.print_formats)
.trigger("change");
this.appframe.set_view("print");
this.page.set_view("print");
}
_f.Frm.prototype.hide_print = function() {
if(this.setup_done) {
this.appframe.set_view("main");
this.page.set_view("main");
}
}
@ -495,6 +495,7 @@ _f.Frm.prototype.setnewdoc = function() {
me.script_manager.trigger("onload");
me.opendocs[me.docname] = true;
me.render_form();
frappe.add_breadcrumbs(me.meta.module, me.doctype)
})
}
@ -679,12 +680,12 @@ _f.Frm.prototype.amend_doc = function() {
_f.Frm.prototype.disable_save = function() {
// IMPORTANT: this function should be called in refresh event
this.save_disabled = true;
this.appframe.set_title_right("", null);
this.page.clear_primary_action();
}
_f.Frm.prototype.enable_save = function() {
this.save_disabled = false;
this.toolbar.set_title_right();
this.toolbar.set_primary_action();
}
_f.Frm.prototype.save_or_update = function() {
@ -726,11 +727,11 @@ _f.Frm.prototype.set_footnote = function(txt) {
_f.Frm.prototype.add_custom_button = function(label, fn, icon, toolbar_or_class) {
this.sidebar.add_user_action(label, fn);
this.page.add_menu_item(label, fn);
}
_f.Frm.prototype.clear_custom_buttons = function() {
this.frm.sidebar.clear_user_actions();
this.page.clear_user_actions();
}
_f.Frm.prototype.add_fetch = function(link_field, src_field, tar_field) {