Create the status-bar in the properties dialog, and it will listen for
on-status event from the model.pull/3/head
parent
1ba5d79978
commit
6057259bdc
|
@ -85,6 +85,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
|
||||||
// Used to generate view for the particular node properties, edit,
|
// Used to generate view for the particular node properties, edit,
|
||||||
// creation.
|
// creation.
|
||||||
getView: function(item, type, el, node, formType, callback, data) {
|
getView: function(item, type, el, node, formType, callback, data) {
|
||||||
|
var that = this;
|
||||||
|
|
||||||
if (!this.type || this.type == '')
|
if (!this.type || this.type == '')
|
||||||
// We have no information, how to generate view for this type.
|
// We have no information, how to generate view for this type.
|
||||||
|
@ -117,6 +118,11 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
|
||||||
info = this.getTreeNodeHierarchy.apply(this, [item]),
|
info = this.getTreeNodeHierarchy.apply(this, [item]),
|
||||||
groups = Backform.generateViewSchema(info, newModel, type, this, node);
|
groups = Backform.generateViewSchema(info, newModel, type, this, node);
|
||||||
|
|
||||||
|
if (type == 'create' || type == 'edit'){
|
||||||
|
newModel.on('on-status', function(e){
|
||||||
|
that.statusBar.html(e.msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
// 'schema' has the information about how to generate the form.
|
// 'schema' has the information about how to generate the form.
|
||||||
if (groups) {
|
if (groups) {
|
||||||
var fields = [];
|
var fields = [];
|
||||||
|
@ -487,8 +493,22 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
|
||||||
view = j.data('obj-view'),
|
view = j.data('obj-view'),
|
||||||
content = $('<div tabindex="1"></div>')
|
content = $('<div tabindex="1"></div>')
|
||||||
.addClass('pg-prop-content col-xs-12'),
|
.addClass('pg-prop-content col-xs-12'),
|
||||||
|
|
||||||
|
// Template function to create the status bar
|
||||||
|
createStatusBar = function(location){
|
||||||
|
var statusBar = $('<div></div>').addClass(
|
||||||
|
'pg-prop-status-bar'
|
||||||
|
).appendTo(j);
|
||||||
|
if (location == "header") {
|
||||||
|
statusBar.appendTo(that.header);
|
||||||
|
} else {
|
||||||
|
statusBar.prependTo(that.footer);
|
||||||
|
}
|
||||||
|
that.statusBar = statusBar;
|
||||||
|
return statusBar;
|
||||||
|
},
|
||||||
// Template function to create the button-group
|
// Template function to create the button-group
|
||||||
createButtons = function(buttons, extraClasses) {
|
createButtons = function(buttons, location, extraClasses) {
|
||||||
// arguments must be non-zero length array of type
|
// arguments must be non-zero length array of type
|
||||||
// object, which contains following attributes:
|
// object, which contains following attributes:
|
||||||
// label, type, extraClasses, register
|
// label, type, extraClasses, register
|
||||||
|
@ -498,7 +518,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
|
||||||
var btnGroup =
|
var btnGroup =
|
||||||
$('<div></div>').addClass(
|
$('<div></div>').addClass(
|
||||||
'pg-prop-btn-group'
|
'pg-prop-btn-group'
|
||||||
).appendTo(j),
|
),
|
||||||
// Template used for creating a button
|
// Template used for creating a button
|
||||||
tmpl = _.template([
|
tmpl = _.template([
|
||||||
'<button type="<%= type %>" ',
|
'<button type="<%= type %>" ',
|
||||||
|
@ -506,6 +526,11 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
|
||||||
'<i class="<%= icon %>"></i> ',
|
'<i class="<%= icon %>"></i> ',
|
||||||
'<%-label%></button>'
|
'<%-label%></button>'
|
||||||
].join(' '));
|
].join(' '));
|
||||||
|
if (location == "header"){
|
||||||
|
btnGroup.appendTo(that.header);
|
||||||
|
}else{
|
||||||
|
btnGroup.appendTo(that.footer);
|
||||||
|
}
|
||||||
if (extraClasses) {
|
if (extraClasses) {
|
||||||
btnGroup.addClass(extraClasses);
|
btnGroup.addClass(extraClasses);
|
||||||
}
|
}
|
||||||
|
@ -546,12 +571,23 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
|
||||||
}
|
}
|
||||||
// Make sure the HTML element is empty.
|
// Make sure the HTML element is empty.
|
||||||
j.empty();
|
j.empty();
|
||||||
|
that.header = $('<div></div>').addClass(
|
||||||
|
'pg-prop-header'
|
||||||
|
).appendTo(j);
|
||||||
|
that.footer = $('<div></div>').addClass(
|
||||||
|
'pg-prop-footer'
|
||||||
|
).appendTo(j);
|
||||||
// Create a view to show the properties in fieldsets
|
// Create a view to show the properties in fieldsets
|
||||||
view = that.getView(item, 'properties', content, data, 'fieldset');
|
view = that.getView(item, 'properties', content, data, 'fieldset');
|
||||||
if (view) {
|
if (view) {
|
||||||
// Save it for release it later
|
// Save it for release it later
|
||||||
j.data('obj-view', view);
|
j.data('obj-view', view);
|
||||||
|
|
||||||
|
// Create status bar
|
||||||
|
createStatusBar('footer');
|
||||||
|
|
||||||
// Create proper buttons
|
// Create proper buttons
|
||||||
|
|
||||||
var buttons = [];
|
var buttons = [];
|
||||||
buttons.push({
|
buttons.push({
|
||||||
label: '{{ _("Edit") }}', type: 'edit',
|
label: '{{ _("Edit") }}', type: 'edit',
|
||||||
|
@ -563,7 +599,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
createButtons(buttons, 'pg-prop-btn-group-above');
|
createButtons(buttons, 'header', 'pg-prop-btn-group-above');
|
||||||
}
|
}
|
||||||
j.append(content);
|
j.append(content);
|
||||||
},
|
},
|
||||||
|
@ -586,6 +622,13 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
|
||||||
// Make sure the HTML element is empty.
|
// Make sure the HTML element is empty.
|
||||||
j.empty();
|
j.empty();
|
||||||
|
|
||||||
|
that.header = $('<div></div>').addClass(
|
||||||
|
'pg-prop-header'
|
||||||
|
).appendTo(j)
|
||||||
|
that.footer = $('<div></div>').addClass(
|
||||||
|
'pg-prop-footer'
|
||||||
|
).appendTo(j);
|
||||||
|
|
||||||
var modelChanged = function(m, o) {
|
var modelChanged = function(m, o) {
|
||||||
var btnGroup = o.find('.pg-prop-btn-group'),
|
var btnGroup = o.find('.pg-prop-btn-group'),
|
||||||
btnSave = btnGroup.find('button[type="save"]'),
|
btnSave = btnGroup.find('button[type="save"]'),
|
||||||
|
@ -620,7 +663,6 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
|
||||||
btn.click(function() {
|
btn.click(function() {
|
||||||
var m = view.model,
|
var m = view.model,
|
||||||
d = m.toJSON(true);
|
d = m.toJSON(true);
|
||||||
|
|
||||||
if (d && !_.isEmpty(d)) {
|
if (d && !_.isEmpty(d)) {
|
||||||
m.save({}, {
|
m.save({}, {
|
||||||
attrs: d,
|
attrs: d,
|
||||||
|
@ -660,9 +702,12 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
|
||||||
setTimeout(function() { editFunc.call(); }, 0);
|
setTimeout(function() { editFunc.call(); }, 0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}], 'pg-prop-btn-group-below');
|
}],'footer' ,'pg-prop-btn-group-below');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Create status bar.
|
||||||
|
createStatusBar('footer');
|
||||||
|
|
||||||
// Add some space, so that - button group does not override the
|
// Add some space, so that - button group does not override the
|
||||||
// space
|
// space
|
||||||
content.addClass('pg-prop-has-btn-group-below');
|
content.addClass('pg-prop-has-btn-group-below');
|
||||||
|
@ -930,7 +975,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
|
||||||
delete res['deleted'];
|
delete res['deleted'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return (_.size(res) == 0 ? null : res);
|
return (_.size(res) == 0 ? null : JSON.stringify(res));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onModelAdd: function(obj) {
|
onModelAdd: function(obj) {
|
||||||
|
@ -1227,7 +1272,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
|
||||||
|
|
||||||
_.each(self.objects, function(k) {
|
_.each(self.objects, function(k) {
|
||||||
var obj = self.get(k);
|
var obj = self.get(k);
|
||||||
res[k] = (obj && obj.toJSON(session));
|
res[k] = (obj && JSON.stringify(obj.toJSON(session)));
|
||||||
});
|
});
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
|
|
|
@ -189,7 +189,7 @@ iframe {
|
||||||
|
|
||||||
.obj_properties .backform-tab {
|
.obj_properties .backform-tab {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
margin: 0px 0px 80px;
|
margin: 0px 0px 110px;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
bottom: 0px;
|
bottom: 0px;
|
||||||
|
@ -356,7 +356,6 @@ iframe {
|
||||||
}
|
}
|
||||||
|
|
||||||
.pg-prop-btn-group {
|
.pg-prop-btn-group {
|
||||||
position: absolute;
|
|
||||||
text-align: right;
|
text-align: right;
|
||||||
background-color: #D2D2D2;
|
background-color: #D2D2D2;
|
||||||
border: 2px solid #A9A9A9;
|
border: 2px solid #A9A9A9;
|
||||||
|
@ -364,12 +363,7 @@ iframe {
|
||||||
right: 0px;
|
right: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pg-prop-btn-group-above {
|
|
||||||
top: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pg-prop-btn-group-below {
|
.pg-prop-btn-group-below {
|
||||||
bottom: 0px;
|
|
||||||
border-color: #A9A9A9;
|
border-color: #A9A9A9;
|
||||||
border-width: 2px 1px 0px;
|
border-width: 2px 1px 0px;
|
||||||
border-style: inset;
|
border-style: inset;
|
||||||
|
@ -595,3 +589,25 @@ table.backgrid tr.new {
|
||||||
.width_percent_60 {
|
.width_percent_60 {
|
||||||
width: 60%;
|
width: 60%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pg-prop-status-bar {
|
||||||
|
left: 0px;
|
||||||
|
right: 0px;
|
||||||
|
background-color: #d2d2d2;
|
||||||
|
color: #b92c28;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pg-prop-header {
|
||||||
|
position: absolute;
|
||||||
|
left: 0px;
|
||||||
|
right: 0px;
|
||||||
|
top :0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pg-prop-footer{
|
||||||
|
position: absolute;
|
||||||
|
left: 0px;
|
||||||
|
right: 0px;
|
||||||
|
bottom :0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue