mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
37 lines
874 B
JavaScript
37 lines
874 B
JavaScript
/* global CloudCmd */
|
|
import {fullstore} from 'fullstore';
|
|
import DOM from './dom/index.js';
|
|
|
|
const sortPrevious = fullstore();
|
|
|
|
const {getPanel} = DOM;
|
|
|
|
export const initSortPanel = () => {
|
|
const {sort, order} = CloudCmd;
|
|
const position = DOM.getPanelPosition();
|
|
|
|
sortPrevious(sort[position]);
|
|
};
|
|
|
|
export const sortPanel = (name, panel = getPanel()) => {
|
|
const {sort, order} = CloudCmd;
|
|
const Info = DOM.CurrentInfo;
|
|
const position = panel.dataset.name.replace('js-', '');
|
|
|
|
if (name !== sortPrevious())
|
|
order[position] = 'asc';
|
|
else if (order[position] === 'asc')
|
|
order[position] = 'desc';
|
|
else
|
|
order[position] = 'asc';
|
|
|
|
sortPrevious(name);
|
|
sort[position] = name;
|
|
const noCurrent = position !== Info.panelPosition;
|
|
|
|
CloudCmd.refresh({
|
|
panel,
|
|
noCurrent,
|
|
});
|
|
};
|
|
|