2017-01-21 16:37:38 -07:00
|
|
|
|
define(['loading'], function (loading) {
|
2016-10-22 22:11:46 -07:00
|
|
|
|
'use strict';
|
2013-05-05 18:15:48 -07:00
|
|
|
|
|
2017-01-21 16:37:38 -07:00
|
|
|
|
function reload(context, itemId) {
|
2013-08-02 13:36:44 -07:00
|
|
|
|
|
2017-01-21 16:37:38 -07:00
|
|
|
|
loading.show();
|
2013-12-28 09:58:13 -07:00
|
|
|
|
|
2016-02-15 21:54:20 -07:00
|
|
|
|
if (itemId) {
|
2016-07-24 11:25:32 -07:00
|
|
|
|
require(['metadataEditor'], function (metadataEditor) {
|
2013-12-28 09:58:13 -07:00
|
|
|
|
|
2017-01-21 16:37:38 -07:00
|
|
|
|
metadataEditor.embed(context.querySelector('.editPageInnerContent'), itemId, ApiClient.serverInfo().Id);
|
2014-02-09 14:11:11 -07:00
|
|
|
|
});
|
2016-02-15 21:54:20 -07:00
|
|
|
|
} else {
|
2017-01-21 16:37:38 -07:00
|
|
|
|
context.querySelector('.editPageInnerContent').innerHTML = '';
|
|
|
|
|
loading.hide();
|
2015-06-29 11:45:42 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-21 16:37:38 -07:00
|
|
|
|
return function (view, params) {
|
2015-07-15 04:26:47 -07:00
|
|
|
|
|
2017-01-21 16:37:38 -07:00
|
|
|
|
view.addEventListener('viewshow', function () {
|
|
|
|
|
reload(this, MetadataEditor.getCurrentItemId());
|
|
|
|
|
});
|
2013-05-22 12:49:12 -07:00
|
|
|
|
|
2016-03-15 22:33:31 -07:00
|
|
|
|
MetadataEditor.setCurrentItemId(null);
|
|
|
|
|
|
2017-01-21 16:37:38 -07:00
|
|
|
|
view.querySelector('.libraryTree').addEventListener('itemclicked', function (event) {
|
|
|
|
|
|
|
|
|
|
var data = event.detail;
|
2013-05-05 18:15:48 -07:00
|
|
|
|
|
2017-01-21 16:37:38 -07:00
|
|
|
|
if (data.id != MetadataEditor.getCurrentItemId()) {
|
2013-05-05 18:15:48 -07:00
|
|
|
|
|
2016-03-15 22:33:31 -07:00
|
|
|
|
MetadataEditor.setCurrentItemId(data.id);
|
2017-01-21 16:37:38 -07:00
|
|
|
|
reload(view, data.id);
|
2013-08-02 13:36:44 -07:00
|
|
|
|
}
|
|
|
|
|
});
|
2017-01-21 16:37:38 -07:00
|
|
|
|
};
|
2016-03-15 22:33:31 -07:00
|
|
|
|
});
|