requirejs("controls/gridview"); requirejs("controls/checkbox"); requirejs("controls/columntracklist"); var automaticallyUpdateMovedFiles = false, foundList = null, sameList = null, notList = null, locatedList = null, unlocatedList = null; function init(params) { resizeable = true; title = _('Locate moved/missing files'); automaticallyUpdateMovedFiles = params.scanRes.automaticallyUpdateMovedFiles; foundList = params.scanRes.foundList; sameList = params.scanRes.sameList; notList = params.scanRes.notList; checkedList = params.scanRes.checkedList; ODS(sprintf('LMMF results in dlg: found: %d, same %d, unlocated: %d, checked: %d', foundList.count, sameList.count, notList.count, checkedList.count)); // preset list views var assignDataList = function (listView, data) { var lv = qid(listView); lv.controlClass.data = data; lv.controlClass.dataSource = lv.controlClass.data; lv.controlClass.invalidateAll(); } foundList.setAllChecked(true); // #15604 assignDataList('lvLocatedList', foundList); assignDataList('lvUnmovedList', sameList); assignDataList('lvUnlocatedList', notList); // initialize tabs var tabs = qid('tabs'); function selecttab(tab, oldtab) { if (oldtab) setVisibility(qid(oldtab), false, { animate: true }); setVisibility(qid(tab), true, { animate: true }); } window.localListen(tabs, 'selected', function (e) { var oldTab; if (e.detail.oldTabIndex >= 0) oldTab = tabs.controlClass.items[e.detail.oldTabIndex].getAttribute('tabname'); selecttab(tabs.controlClass.items[e.detail.tabIndex].getAttribute('tabname'), oldTab); }); tabs.controlClass.selectedIndex = 0; window.localListen(qid('btnUpdate'), 'click', function () { qid('btnUpdate').controlClass.disabled = true; var ar = []; if (qid('ChBUpdateTracks').controlClass.checked) { locatedList = foundList.getCheckedList(); ar.push(locatedList.whenLoaded()); } if (qid('ChBRemoveTracks').controlClass.checked) { unlocatedList = notList.getCheckedList(); ar.push(unlocatedList.whenLoaded()); } window.localPromise(whenAll(ar)).then(function () { modalResult = 1; }); }); } function getData() { var ret = {}; if (qid('ChBUpdateTracks').controlClass.checked) { ret.locatedList = locatedList; } if (qid('ChBRemoveTracks').controlClass.checked) { ret.unlocatedList = unlocatedList; } return ret; } // myLocatedListView -------------------------------------------- function myLocatedListView(element) { ColumnTrackList.call(this, element); var tracksList = this; this.showHeader = true; this.defaultColumns = new Array(); this.defaultColumns.push({ visible: true, title: '', width: 20, order: 1, headerRenderer: ColumnTrackList.prototype.headerRenderers.renderCheck, setupCell: ColumnTrackList.prototype.cellSetups.setupCheckbox, bindData: ColumnTrackList.prototype.defaultBinds.bindCheckboxCell }); this.defaultColumns.push({ visible: true, title: _('Artist'), width: 180, order: 2, bindData: function (div, item) { div.innerText = item.SD.artist; }, columnType: 'artist', }); this.defaultColumns.push({ visible: true, title: _('File'), width: 180, order: 3, bindData: function (div, item) { div.innerText = item.SD.title; }, columnType: 'title', }); this.defaultColumns.push({ visible: true, title: _('New Path'), width: 280, order: 4, bindData: function (div, item) { div.innerText = item.newPath; }, }); this.defaultColumns.push({ visible: true, title: _('Old Path'), width: 280, order: 5, bindData: function (div, item) { div.innerText = item.SD.path; }, columnType: 'path', }); this.setColumns(this.defaultColumns); } myLocatedListView.prototype = Object.create(ColumnTrackList.prototype); // myUnmovedListView -------------------------------------------- function myUnmovedListView(element) { ColumnTrackList.call(this, element); var tracksList = this; this.showHeader = true; this.defaultColumns = new Array(); this.defaultColumns.push({ visible: true, title: _('Artist'), width: 180, order: 1, bindData: function (div, item) { div.innerText = item.SD.artist; }, columnType: 'artist', }); this.defaultColumns.push({ visible: true, title: _('File'), width: 180, order: 2, bindData: function (div, item) { div.innerText = item.SD.title; }, columnType: 'title', }); this.defaultColumns.push({ visible: true, title: _('Path'), width: 280, order: 3, bindData: function (div, item) { div.innerText = item.SD.path; }, columnType: 'path', }); this.setColumns(this.defaultColumns); } myUnmovedListView.prototype = Object.create(ColumnTrackList.prototype); // myUnlocatedListView -------------------------------------------- function myUnlocatedListView(element) { ColumnTrackList.call(this, element); var tracksList = this; this.showHeader = true; this.defaultColumns = new Array(); this.defaultColumns.push({ visible: true, title: '', width: 20, order: 1, headerRenderer: ColumnTrackList.prototype.headerRenderers.renderCheck, setupCell: ColumnTrackList.prototype.cellSetups.setupCheckbox, bindData: ColumnTrackList.prototype.defaultBinds.bindCheckboxCell }); this.defaultColumns.push({ visible: true, title: _('Artist'), width: 180, order: 2, bindData: function (div, item) { div.innerText = item.SD.artist; }, columnType: 'artist', }); this.defaultColumns.push({ visible: true, title: _('File'), width: 180, order: 3, bindData: function (div, item) { div.innerText = item.SD.title; }, columnType: 'title', }); this.defaultColumns.push({ visible: true, title: _('Path'), width: 280, order: 4, bindData: function (div, item) { div.innerText = item.SD.path; }, columnType: 'path', }); this.setColumns(this.defaultColumns); } myUnlocatedListView.prototype = Object.create(ColumnTrackList.prototype);