Difference between revisions of "Widget:DCTList"
From LINKS Community Center
(8 intermediate revisions by the same user not shown) | |||
Line 282: | Line 282: | ||
* @property {FuncData} functions | * @property {FuncData} functions | ||
* @property {string} usedByDmo | * @property {string} usedByDmo | ||
+ | * @property {string} archived | ||
* @property {string} hasUC | * @property {string} hasUC | ||
* @property {string} logo | * @property {string} logo | ||
Line 366: | Line 367: | ||
const DMO_PROP = 'Used by Practitioners'; | const DMO_PROP = 'Used by Practitioners'; | ||
const UC_PROP = 'Use Cases available'; | const UC_PROP = 'Use Cases available'; | ||
+ | const ARCHIVED = 'Is Archived'; | ||
const dctQuery = '[[Category:Disaster Community Technology]]' | const dctQuery = '[[Category:Disaster Community Technology]]' | ||
− | + '[[Is Archived::No]]' | + | // + '[[Is Archived::No]]' |
+ '|limit=500' | + '|limit=500' | ||
+ | + '|?' + ARCHIVED | ||
+ '|?' + IMG_PROP | + '|?' + IMG_PROP | ||
+ '|?' + DATASRC_PROP | + '|?' + DATASRC_PROP | ||
Line 390: | Line 393: | ||
dct.usedByDmo = dctResult.printouts[DMO_PROP][0] === 't' ? 'yes' : 'no'; // not quite, but we only care about yes | dct.usedByDmo = dctResult.printouts[DMO_PROP][0] === 't' ? 'yes' : 'no'; // not quite, but we only care about yes | ||
dct.hasUC = dctResult.printouts[UC_PROP][0] === 't' ? 'yes' : 'no'; // not quite, but we only care about yes | dct.hasUC = dctResult.printouts[UC_PROP][0] === 't' ? 'yes' : 'no'; // not quite, but we only care about yes | ||
+ | dct.archived = dctResult.printouts[ARCHIVED][0] === 't' ? 'yes' : 'no'; // not quite, but we only care about yes | ||
dct.functions = new Map(); | dct.functions = new Map(); | ||
Line 449: | Line 453: | ||
? filterState.hasUC === dct.hasUC | ? filterState.hasUC === dct.hasUC | ||
: true; | : true; | ||
+ | const archivedCheck = filterState.showArchived | ||
+ | ? true | ||
+ | : dct.archived !== 'yes'; | ||
− | return sourcesCheck && functionsCheck && businessModelCheck && dmUseCheck && ucCheck; | + | return sourcesCheck && functionsCheck && businessModelCheck && dmUseCheck && ucCheck && archivedCheck; |
} | } | ||
Line 462: | Line 469: | ||
} | } | ||
− | |||
const filterState = {}; | const filterState = {}; | ||
Line 469: | Line 475: | ||
const funcOpts = new Map(); | const funcOpts = new Map(); | ||
functionFilterBlocks.forEach(block => { | functionFilterBlocks.forEach(block => { | ||
− | |||
− | |||
const cat = block.querySelector('input.func-cat'); | const cat = block.querySelector('input.func-cat'); | ||
if (cat.checked) { | if (cat.checked) { | ||
Line 493: | Line 497: | ||
if (document.getElementById('used-by-practitioners').checked) filterState.usedByDmo = 'yes'; | if (document.getElementById('used-by-practitioners').checked) filterState.usedByDmo = 'yes'; | ||
if (document.getElementById('has-use-case').checked) filterState.hasUC = 'yes'; | if (document.getElementById('has-use-case').checked) filterState.hasUC = 'yes'; | ||
+ | if (document.getElementById('show-archived').checked) filterState.showArchived = 'yes'; | ||
table.setFilter(dctFilter, filterState); | table.setFilter(dctFilter, filterState); | ||
Line 576: | Line 581: | ||
field: 'name', | field: 'name', | ||
minWidth: 300, // required for responsiveness when using fitColumns | minWidth: 300, // required for responsiveness when using fitColumns | ||
+ | widthGrow: 2, | ||
formatter: function (cell) { | formatter: function (cell) { | ||
/** @type {DCT} */ | /** @type {DCT} */ | ||
const dct = cell.getData(); | const dct = cell.getData(); | ||
− | let out = '<a href="' + dct.url + '">' + dct.name + '</a><br>'; | + | let out = '<a href="' + dct.url + '" translate="no">' + dct.name + '</a><br>'; |
+ | if (dct.archived.toLowerCase() === 'yes') { | ||
+ | out += '<small><span class="badge lcc-badge-grey">Archived</span></small> '; | ||
+ | } | ||
if (dct.businessModel.includes(FREE_KEY)) { | if (dct.businessModel.includes(FREE_KEY)) { | ||
out += '<small><span class="badge lcc-badge-green">' + FREE_KEY + '</span></small> '; | out += '<small><span class="badge lcc-badge-green">' + FREE_KEY + '</span></small> '; | ||
Line 590: | Line 599: | ||
} | } | ||
if (dct.hasUC.toLowerCase() === 'yes') { | if (dct.hasUC.toLowerCase() === 'yes') { | ||
− | out += '<small><span class="badge badge- | + | out += '<small><span class="badge lcc-badge-purple">Use case available</span></small> '; |
} | } | ||
Line 599: | Line 608: | ||
title: 'Functions', | title: 'Functions', | ||
field: 'functions', | field: 'functions', | ||
− | minWidth: | + | minWidth: 200, // required for responsiveness when using fitColumns |
cssClass: 'functions-cell', | cssClass: 'functions-cell', | ||
formatter: function (cell) { | formatter: function (cell) { | ||
Line 682: | Line 691: | ||
// ... | // ... | ||
} | } | ||
+ | |||
+ | applyFilters(); | ||
}); | }); | ||
Line 988: | Line 999: | ||
<input type="checkbox" id="has-use-case" value="yes"> | <input type="checkbox" id="has-use-case" value="yes"> | ||
<label for="has-use-case">Use case available</label> | <label for="has-use-case">Use case available</label> | ||
+ | </div> | ||
+ | <div> | ||
+ | <input type="checkbox" id="show-archived" value="yes"> | ||
+ | <label for="show-archived">Show archived</label> | ||
</div> | </div> | ||
</div> | </div> |
Latest revision as of 15:30, 19 December 2023
DCT list widget.
Currently in use – do not modify!