forked from 0x2620/pandora
clean up entities dialog
This commit is contained in:
parent
f75a476e6c
commit
bdc7d7aa1f
1 changed files with 22 additions and 20 deletions
|
@ -81,6 +81,7 @@ pandora.ui.entitiesDialog = function(options) {
|
||||||
}
|
}
|
||||||
}), callback);
|
}), callback);
|
||||||
},
|
},
|
||||||
|
selected: ui.entitiesSelection[type] || [],
|
||||||
sort: [{key: 'name', operator: '+'}],
|
sort: [{key: 'name', operator: '+'}],
|
||||||
scrollbarVisible: true,
|
scrollbarVisible: true,
|
||||||
unique: 'id',
|
unique: 'id',
|
||||||
|
@ -96,16 +97,7 @@ pandora.ui.entitiesDialog = function(options) {
|
||||||
$listStatus.html(text[0].toUpperCase() + text.slice(1));
|
$listStatus.html(text[0].toUpperCase() + text.slice(1));
|
||||||
},
|
},
|
||||||
select: function(data) {
|
select: function(data) {
|
||||||
var text = Ox.formatCount(
|
pandora.UI.set('entitiesSelection.' + type, data.ids);
|
||||||
data.ids.length,
|
|
||||||
Ox._('entity'),
|
|
||||||
Ox._('entities')
|
|
||||||
) + ' ' + Ox._('selected');
|
|
||||||
selected = data.ids;
|
|
||||||
renderEntity();
|
|
||||||
$deselectButton[data.ids.length ? 'show' : 'hide']();
|
|
||||||
renderForm();
|
|
||||||
$itemStatus.html(text[0].toUpperCase() + text.slice(1));
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
@ -162,7 +154,6 @@ pandora.ui.entitiesDialog = function(options) {
|
||||||
pandora.api.addEntity({
|
pandora.api.addEntity({
|
||||||
type: type
|
type: type
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
Ox.print('$$$$', result);
|
|
||||||
Ox.Request.clearCache('findEntities');
|
Ox.Request.clearCache('findEntities');
|
||||||
$list.reloadList().options({
|
$list.reloadList().options({
|
||||||
selected: [result.data.id]
|
selected: [result.data.id]
|
||||||
|
@ -186,10 +177,7 @@ pandora.ui.entitiesDialog = function(options) {
|
||||||
.hide()
|
.hide()
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
click: function() {
|
click: function() {
|
||||||
pandora.UI.set(
|
pandora.UI.set('entitiesSelection.' + type, []);
|
||||||
'entitiesSelection.' + type,
|
|
||||||
[]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
@ -288,6 +276,9 @@ pandora.ui.entitiesDialog = function(options) {
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
// resize: ...
|
// resize: ...
|
||||||
|
pandora_entitiesselection: function() {
|
||||||
|
selectEntities();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function deleteEntities() {
|
function deleteEntities() {
|
||||||
|
@ -304,7 +295,7 @@ pandora.ui.entitiesDialog = function(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderEntity() {
|
function renderEntity() {
|
||||||
var id = selected[0];
|
var id = ui.entitiesSelection['type'][0];
|
||||||
if (!id) {
|
if (!id) {
|
||||||
$entity.empty();
|
$entity.empty();
|
||||||
return;
|
return;
|
||||||
|
@ -314,7 +305,7 @@ pandora.ui.entitiesDialog = function(options) {
|
||||||
type: type,
|
type: type,
|
||||||
view: 'entity'
|
view: 'entity'
|
||||||
}, function(html) {
|
}, function(html) {
|
||||||
if (id != selected[0]) {
|
if (id != ui.entitiesSelection['type'][0]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$entity.html(html);
|
$entity.html(html);
|
||||||
|
@ -322,7 +313,7 @@ pandora.ui.entitiesDialog = function(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderForm() {
|
function renderForm() {
|
||||||
var id = selected[0];
|
var id = ui.entitiesSelection['type'][0];
|
||||||
if (!id) {
|
if (!id) {
|
||||||
$form.empty();
|
$form.empty();
|
||||||
return;
|
return;
|
||||||
|
@ -330,7 +321,7 @@ pandora.ui.entitiesDialog = function(options) {
|
||||||
pandora.api.getEntity({
|
pandora.api.getEntity({
|
||||||
id: id
|
id: id
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
if (id != selected[0]) {
|
if (id != ui.entitiesSelection['type'][0]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var keys = Ox.getObjectById(pandora.site.entities, type).keys;
|
var keys = Ox.getObjectById(pandora.site.entities, type).keys;
|
||||||
|
@ -384,7 +375,18 @@ pandora.ui.entitiesDialog = function(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectEntities() {
|
function selectEntities() {
|
||||||
// ...
|
var text = Ox.formatCount(
|
||||||
|
data.ids.length,
|
||||||
|
Ox._('entity'),
|
||||||
|
Ox._('entities')
|
||||||
|
) + ' ' + Ox._('selected');
|
||||||
|
renderEntity();
|
||||||
|
$itemMenu.setItemTitle('delete', Ox._('Delete {0}...', [
|
||||||
|
Ox._(ui.entitiesSelection[type].length < 2 ? 'Entity' : 'Entities')
|
||||||
|
]));
|
||||||
|
$deselectButton[data.ids.length ? 'show' : 'hide']();
|
||||||
|
renderForm();
|
||||||
|
$itemStatus.html(text[0].toUpperCase() + text.slice(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateForm() {
|
function updateForm() {
|
||||||
|
|
Loading…
Reference in a new issue