mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[feature-136] init delete models modal
This commit is contained in:
@@ -533,5 +533,13 @@
|
||||
"ReleaseImg": "https://cdn.akamai.steamstatic.com/steamcommunity/public/images/clans/32055887/c328e407367e9914abaf92f609501877ee5abb63.png",
|
||||
"ReleaseDate": "1680623885",
|
||||
"year": "2023"
|
||||
},
|
||||
{
|
||||
"BSVersion": "1.29.4",
|
||||
"BSManifest": "6291266771922375922",
|
||||
"ReleaseURL": "https://steamcommunity.com/games/620980/announcements/detail/3708194993422325380",
|
||||
"ReleaseImg": "https://cdn.akamai.steamstatic.com/steamcommunity/public/images/clans/32055887/9c3d476c03e4a2ac72ca5df016b7c94d242b41cb.png",
|
||||
"ReleaseDate": "1683644991",
|
||||
"year": "2023"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,36 @@
|
||||
import React, { useState } from 'react'
|
||||
import { ModalComponent, ModalExitCode } from 'renderer/services/modale.service'
|
||||
import { BsmLocalModel } from 'shared/models/models/bsm-local-model.interface'
|
||||
import BeatConflict from '../../../../../../assets/images/apngs/beat-conflict.png'
|
||||
import { BsmImage } from 'renderer/components/shared/bsm-image.component'
|
||||
import { BsmCheckbox } from 'renderer/components/shared/bsm-checkbox.component'
|
||||
import { BsmButton } from 'renderer/components/shared/bsm-button.component'
|
||||
import { useTranslation } from 'renderer/hooks/use-translation.hook'
|
||||
|
||||
export const DeleteModelsModal: ModalComponent<void, {models: BsmLocalModel[], linked: boolean}> = ({resolver, data}) => {
|
||||
|
||||
const t = useTranslation();
|
||||
const [remember, setRemember] = useState(false);
|
||||
|
||||
const isMultiple = data.models.length > 1;
|
||||
console.log(isMultiple);
|
||||
|
||||
return (
|
||||
<form className="text-gray-800 dark:text-gray-200">
|
||||
<h1 className="text-3xl uppercase tracking-wide w-full text-center">TODO TITLE</h1>
|
||||
<BsmImage className="mx-auto h-24" image={BeatConflict}/>
|
||||
<p className="max-w-sm w-full">TODO DESK</p>
|
||||
{data.linked && <p className="text-sm italic mt-2 cursor-help w-fit" title="TODO TITLE">TODO LINKED</p>}
|
||||
{!isMultiple && (
|
||||
<div className="flex items-center relative py-2 gap-1 mt-1">
|
||||
<BsmCheckbox className="h-5 relative z-[1]" checked={remember} onChange={(val) => setRemember(val)}/>
|
||||
<span className="italic">{t("modals.misc.remember-my-choice")}</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="grid grid-flow-col grid-cols-2 gap-4 mt-2">
|
||||
<BsmButton typeColor="cancel" className="rounded-md text-center transition-all" onClick={() => resolver({exitCode: ModalExitCode.CANCELED})} withBar={false} text="misc.cancel"/>
|
||||
<BsmButton typeColor="primary" className="rounded-md text-center transition-all" onClick={() => resolver({exitCode: ModalExitCode.COMPLETED})} withBar={false} text="misc.delete"/>
|
||||
</div>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import { ProgressionInterface } from "shared/models/progress-bar";
|
||||
import { ArchiveProgress } from "shared/models/archive.interface";
|
||||
import { NotificationService } from "../notification.service";
|
||||
import { ConfigurationService } from "../configuration.service";
|
||||
import { DeleteModelsModal } from "renderer/components/modal/modal-types/models/delete-models-modal.component";
|
||||
|
||||
export class ModelsManagerService {
|
||||
|
||||
@@ -113,21 +114,26 @@ export class ModelsManagerService {
|
||||
}
|
||||
|
||||
public async deleteModels(models: BsmLocalModel[], version?: BSVersion): Promise<boolean>{
|
||||
|
||||
const types = Array.from(new Set(models.map(m => m.type)));
|
||||
|
||||
const modelsLinked = await (async () => { // USE AND COMPUTE ONLY IF NEEDED (askModal)
|
||||
for(const type of types){
|
||||
if(!(await this.isModelsLinked(version, type))){ continue; }
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
})();
|
||||
|
||||
|
||||
const askModal = models.length > 1 || !this.config.get<boolean>(ModelsManagerService.REMEMBER_CHOICE_DELETE_MODEL_KEY);
|
||||
|
||||
// ADD MODAL HERE
|
||||
console.log(models);
|
||||
|
||||
if(askModal){
|
||||
|
||||
const types = Array.from(new Set(models.map(m => m.type)));
|
||||
|
||||
const linked = await (async () => {
|
||||
for(const type of types){
|
||||
if(!(await this.isModelsLinked(version, type))){ continue; }
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
})();
|
||||
|
||||
const res = await this.modalService.openModal(DeleteModelsModal, { models, linked });
|
||||
if(res.exitCode !== ModalExitCode.COMPLETED){ return false; }
|
||||
}
|
||||
|
||||
const showProgressBar = this.progressBar.require();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user