MDL-69454 core_search: consistent content bank search
[moodle.git] / contentbank / amd / src / selectors.js
CommitLineData
f9b6849b
SA
1// This file is part of Moodle - http://moodle.org/
2//
3// Moodle is free software: you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// Moodle is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
15
16/**
17 * Define all of the selectors we will be using on the contentbank interface.
18 *
19 * @module core_contentbank/selectors
20 * @package core_contentbank
21 * @copyright 2020 Sara Arjona <sara@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25/**
26 * A small helper function to build queryable data selectors.
27 *
28 * @method getDataSelector
29 * @param {String} name
30 * @param {String} value
31 * @return {string}
32 */
33const getDataSelector = (name, value) => {
34 return `[data-${name}="${value}"]`;
35};
36
37export default {
38 regions: {
39 cbcontentname: getDataSelector('region', 'cb-content-name'),
e695d9d0
BB
40 contentbank: getDataSelector('region', 'contentbank'),
41 filearea: getDataSelector('region', 'filearea')
f9b6849b
SA
42 },
43 actions: {
44 search: getDataSelector('action', 'searchcontent'),
dcfb713c 45 clearSearch: getDataSelector('action', 'clearsearch'),
e695d9d0
BB
46 viewgrid: getDataSelector('action', 'viewgrid'),
47 viewlist: getDataSelector('action', 'viewlist'),
48 sortname: getDataSelector('action', 'sortname'),
49 sortdate: getDataSelector('action', 'sortdate'),
50 sortsize: getDataSelector('action', 'sortsize'),
191448af
SA
51 sorttype: getDataSelector('action', 'sorttype'),
52 sortauthor: getDataSelector('action', 'sortauthor'),
f9b6849b
SA
53 },
54 elements: {
e695d9d0 55 listitem: '.cb-listitem',
f9b6849b
SA
56 cbnavbarbreadcrumb: '.cb-navbar-breadbrumb',
57 cbnavbartotalsearch: '.cb-navbar-totalsearch',
f9b6849b 58 searchinput: '#searchinput',
e695d9d0 59 sortbutton: '.cb-btnsort'
f9b6849b
SA
60 },
61};