Collections can now have games set to be always included or excluded (#96)
* Added drop down menus to collections to select if games should be always included * Now able to add games to a collection from the game info page
This commit is contained in:
74
gaseous-server/wwwroot/pages/dialogs/collectionaddgame.html
Normal file
74
gaseous-server/wwwroot/pages/dialogs/collectionaddgame.html
Normal file
@@ -0,0 +1,74 @@
|
||||
<p>
|
||||
Select collection to add game to:
|
||||
</p>
|
||||
|
||||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<select id="collection_addgame" style="width: 100%;"></select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-top: 15px;">
|
||||
<input type="checkbox" id="collection_rebuild" style="margin-right: 5px;" /><label for="collection_rebuild">Rebuild Collection</label>
|
||||
</td>
|
||||
<td style="text-align: right; padding-top: 15px;">
|
||||
<button id="collection_cancelbtn" value="Cancel" onclick="closeSubDialog();">Cancel</button>
|
||||
<button id="collection_addbtn" value="Add" onclick="AddToCollection();">Add</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<script type="text/javascript">
|
||||
document.getElementById('collection_addgame').innerHTML = "<option value='0' selected='selected'>Select collection</option>";
|
||||
|
||||
$('#collection_addgame').select2({
|
||||
ajax: {
|
||||
url: '/api/v1/Collections',
|
||||
placeholder: 'Select collection',
|
||||
processResults: function (data) {
|
||||
var arr = [];
|
||||
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
arr.push({
|
||||
id: data[i].id,
|
||||
text: data[i].name
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
results: arr
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function AddToCollection() {
|
||||
var CollectionId = Number(document.getElementById('collection_addgame').value);
|
||||
var PlatformId = modalVariables;
|
||||
var GameId = getQueryString('id', 'int');
|
||||
var RebuildCollection = '';
|
||||
if (document.getElementById('collection_rebuild').checked == true) {
|
||||
RebuildCollection = '?Rebuild=true';
|
||||
}
|
||||
var responseBody = {
|
||||
"PlatformId": PlatformId,
|
||||
"GameId": GameId,
|
||||
"InclusionState": "AlwaysInclude"
|
||||
};
|
||||
|
||||
if (CollectionId != 0) {
|
||||
ajaxCall(
|
||||
'/api/v1/Collections/' + CollectionId + '/AlwaysInclude' + RebuildCollection,
|
||||
'PATCH',
|
||||
function (result) {
|
||||
closeSubDialog();
|
||||
},
|
||||
function (error) {
|
||||
console.log(JSON.stringify(error));
|
||||
},
|
||||
JSON.stringify(responseBody)
|
||||
);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -254,6 +254,8 @@
|
||||
$('#collection_includebios').select2();
|
||||
|
||||
if (modalVariables) {
|
||||
var modalAlwaysInclude = [];
|
||||
|
||||
// edit mode
|
||||
ajaxCall(
|
||||
'/api/v1/Collections/' + modalVariables,
|
||||
@@ -270,6 +272,8 @@
|
||||
$('#collection_directorylayout').val(result.folderStructure).trigger('change');
|
||||
}
|
||||
$('#collection_includebios').val(result.includeBIOSFiles.toString()).trigger('change');
|
||||
modalAlwaysInclude = result.alwaysInclude;
|
||||
console.log(JSON.stringify(modalAlwaysInclude));
|
||||
|
||||
// fill select2 controls
|
||||
$.ajax(
|
||||
@@ -372,6 +376,25 @@
|
||||
var players = GetDropDownIds('#collection_players');
|
||||
var playerperspectives = GetDropDownIds('#collection_playerperspectives');
|
||||
var themes = GetDropDownIds('#collection_themes');
|
||||
var alwaysInclude = [];
|
||||
var alwaysIncludeSelections = document.getElementsByName('collections_preview_always');
|
||||
if (alwaysIncludeSelections.length > 0) {
|
||||
for (var i = 0; i < alwaysIncludeSelections.length; i++) {
|
||||
if (alwaysIncludeSelections[i].value != "None") {
|
||||
var alwaysIncludeItem = {
|
||||
"platformId": Number(alwaysIncludeSelections[i].getAttribute('data-platform')),
|
||||
"gameId": Number(alwaysIncludeSelections[i].getAttribute('data-game')),
|
||||
"inclusionState": alwaysIncludeSelections[i].value
|
||||
};
|
||||
alwaysInclude.push(alwaysIncludeItem);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
alwaysInclude = modalAlwaysInclude;
|
||||
}
|
||||
|
||||
modalAlwaysInclude = alwaysInclude;
|
||||
console.log(JSON.stringify(modalAlwaysInclude));
|
||||
|
||||
var item = {
|
||||
"name": document.getElementById('collection_name').value,
|
||||
@@ -387,7 +410,8 @@
|
||||
"maximumBytesPerPlatform": GetNumberFieldValue('collection_maxplatformsize'),
|
||||
"maximumCollectionSizeInBytes": GetNumberFieldValue('collection_maxcollectionsize'),
|
||||
"folderStructure": GetNumberFieldValue('collection_directorylayout', "Standard"),
|
||||
"includeBIOSFiles": GetBooleanFieldValue('collection_includebios')
|
||||
"includeBIOSFiles": GetBooleanFieldValue('collection_includebios'),
|
||||
"alwaysInclude": alwaysInclude
|
||||
}
|
||||
|
||||
return item;
|
||||
@@ -451,6 +475,7 @@
|
||||
}
|
||||
|
||||
function DisplayPreview(data, targetDiv) {
|
||||
console.log(JSON.stringify(data));
|
||||
var container = document.getElementById(targetDiv);
|
||||
container.innerHTML = '';
|
||||
|
||||
@@ -494,7 +519,48 @@
|
||||
var gameTitleCell = document.createElement('th');
|
||||
gameTitleCell.setAttribute('colspan', 2);
|
||||
gameTitleCell.className = 'collections_preview_gametitlecell';
|
||||
gameTitleCell.innerHTML = gameItem.name;
|
||||
|
||||
// game always include popup
|
||||
var gameTitleInclusion = document.createElement('select');
|
||||
gameTitleInclusion.id = 'collections_preview_always_' + platformItem.id + '_' + gameItem.id;
|
||||
gameTitleInclusion.name = 'collections_preview_always';
|
||||
gameTitleInclusion.setAttribute('data-platform', platformItem.id);
|
||||
gameTitleInclusion.setAttribute('data-game', gameItem.id);
|
||||
gameTitleInclusion.style.float = 'right';
|
||||
|
||||
var gameTitleInclusionOptions = [
|
||||
{
|
||||
"value": "None",
|
||||
"text": "Automatic"
|
||||
},
|
||||
{
|
||||
"value": "AlwaysInclude",
|
||||
"text": "Always Include"
|
||||
},
|
||||
{
|
||||
"value": "AlwaysExclude",
|
||||
"text": "Always Exclude"
|
||||
}
|
||||
];
|
||||
for (var i = 0; i < gameTitleInclusionOptions.length; i++) {
|
||||
var gameTitleInclusionOption = document.createElement('option');
|
||||
gameTitleInclusionOption.value = gameTitleInclusionOptions[i].value;
|
||||
gameTitleInclusionOption.innerHTML = gameTitleInclusionOptions[i].text;
|
||||
|
||||
if (gameItem.inclusionStatus) {
|
||||
if (gameItem.inclusionStatus.inclusionState == gameTitleInclusionOptions[i].value) {
|
||||
gameTitleInclusionOption.selected = 'selected';
|
||||
}
|
||||
}
|
||||
|
||||
gameTitleInclusion.appendChild(gameTitleInclusionOption);
|
||||
}
|
||||
gameTitleCell.appendChild(gameTitleInclusion);
|
||||
|
||||
// game title label
|
||||
var gameTitleLabel = document.createElement('span');
|
||||
gameTitleLabel.innerHTML = gameItem.name;
|
||||
gameTitleCell.appendChild(gameTitleLabel);
|
||||
|
||||
gameItemRow.appendChild(gameTitleCell);
|
||||
|
||||
@@ -541,7 +607,7 @@
|
||||
container.appendChild(collectionTable);
|
||||
|
||||
var collectionSize = document.getElementById('collectionedit_previewbox_size');
|
||||
collectionSize.innerHTML = "Collection size: " + formatBytes(data.collectionProjectedSizeBytes);
|
||||
collectionSize.innerHTML = "Estimated uncompressed collection size: " + formatBytes(data.collectionProjectedSizeBytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user