exceptions adding in closed elements
This commit is contained in:
parent
88bd28e949
commit
a2b6c7c684
10 changed files with 179 additions and 82 deletions
|
|
@ -2,7 +2,7 @@ from typing import List, TYPE_CHECKING
|
|||
|
||||
from PyQt6.QtWidgets import QMessageBox, QDialog
|
||||
|
||||
from warchron.constants import ItemType, RefreshScope
|
||||
from warchron.constants import RefreshScope
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from warchron.controller.app_controller import AppController
|
||||
|
|
@ -13,6 +13,9 @@ from warchron.controller.dtos import (
|
|||
SectorDTO,
|
||||
RoundDTO,
|
||||
)
|
||||
from warchron.model.campaign import Campaign
|
||||
from warchron.model.campaign_participant import CampaignParticipant
|
||||
from warchron.model.sector import Sector
|
||||
from warchron.model.closure_service import ClosureService
|
||||
from warchron.view.campaign_dialog import CampaignDialog
|
||||
from warchron.view.campaign_participant_dialog import CampaignParticipantDialog
|
||||
|
|
@ -68,9 +71,9 @@ class CampaignController:
|
|||
return False
|
||||
return True
|
||||
|
||||
def add_campaign(self) -> None:
|
||||
def create_campaign(self) -> Campaign | None:
|
||||
if not self.app.navigation.selected_war_id:
|
||||
return
|
||||
return None
|
||||
dialog = CampaignDialog(
|
||||
self.app.view,
|
||||
default_month=self.app.model.get_default_campaign_values(
|
||||
|
|
@ -78,18 +81,18 @@ class CampaignController:
|
|||
)["month"],
|
||||
)
|
||||
if dialog.exec() != QDialog.DialogCode.Accepted:
|
||||
return
|
||||
return None
|
||||
name = dialog.get_campaign_name()
|
||||
month = dialog.get_campaign_month()
|
||||
if not self._validate_campaign_inputs(name, month):
|
||||
return
|
||||
camp = self.app.model.add_campaign(
|
||||
return None
|
||||
return self.app.model.add_campaign(
|
||||
self.app.navigation.selected_war_id, name, month
|
||||
)
|
||||
self.app.is_dirty = True
|
||||
self.app.navigation.refresh_and_select(
|
||||
RefreshScope.WARS_TREE, item_type=ItemType.CAMPAIGN, item_id=camp.id
|
||||
)
|
||||
# self.app.is_dirty = True
|
||||
# self.app.navigation.refresh_and_select(
|
||||
# RefreshScope.WARS_TREE, item_type=ItemType.CAMPAIGN, item_id=camp.id
|
||||
# )
|
||||
|
||||
def edit_campaign(self, campaign_id: str) -> None:
|
||||
camp = self.app.model.get_campaign(campaign_id)
|
||||
|
|
@ -128,9 +131,9 @@ class CampaignController:
|
|||
|
||||
# Campaign participant methods
|
||||
|
||||
def add_campaign_participant(self) -> None:
|
||||
def create_campaign_participant(self) -> CampaignParticipant | None:
|
||||
if not self.app.navigation.selected_campaign_id:
|
||||
return
|
||||
return None
|
||||
participants = self.app.model.get_available_war_participants(
|
||||
self.app.navigation.selected_campaign_id
|
||||
)
|
||||
|
|
@ -140,17 +143,15 @@ class CampaignController:
|
|||
]
|
||||
dialog = CampaignParticipantDialog(self.app.view, participants=part_opts)
|
||||
if dialog.exec() != QDialog.DialogCode.Accepted:
|
||||
return
|
||||
return None
|
||||
player_id = dialog.get_player_id()
|
||||
leader = dialog.get_participant_leader()
|
||||
theme = dialog.get_participant_theme()
|
||||
if not player_id:
|
||||
return
|
||||
self.app.model.add_campaign_participant(
|
||||
return None
|
||||
return self.app.model.add_campaign_participant(
|
||||
self.app.navigation.selected_campaign_id, player_id, leader, theme
|
||||
)
|
||||
self.app.is_dirty = True
|
||||
self.app.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
|
||||
|
||||
def edit_campaign_participant(self, participant_id: str) -> None:
|
||||
camp_part = self.app.model.get_campaign_participant(participant_id)
|
||||
|
|
@ -191,9 +192,9 @@ class CampaignController:
|
|||
# allow same objectives in different fields?
|
||||
return True
|
||||
|
||||
def add_sector(self) -> None:
|
||||
def create_sector(self) -> Sector | None:
|
||||
if not self.app.navigation.selected_campaign_id:
|
||||
return
|
||||
return None
|
||||
war = self.app.model.get_war_by_campaign(
|
||||
self.app.navigation.selected_campaign_id
|
||||
)
|
||||
|
|
@ -212,7 +213,7 @@ class CampaignController:
|
|||
self.app.view, default_name="", rounds=rnd_objs, objectives=obj_dtos
|
||||
)
|
||||
if dialog.exec() != QDialog.DialogCode.Accepted:
|
||||
return
|
||||
return None
|
||||
name = dialog.get_sector_name()
|
||||
round_id = dialog.get_round_id()
|
||||
major_id = dialog.get_major_id()
|
||||
|
|
@ -223,8 +224,8 @@ class CampaignController:
|
|||
if not self._validate_sector_inputs(
|
||||
name, round_id, major_id, minor_id, influence_id
|
||||
):
|
||||
return
|
||||
self.app.model.add_sector(
|
||||
return None
|
||||
return self.app.model.add_sector(
|
||||
self.app.navigation.selected_campaign_id,
|
||||
name,
|
||||
round_id,
|
||||
|
|
@ -234,8 +235,6 @@ class CampaignController:
|
|||
mission,
|
||||
description,
|
||||
)
|
||||
self.app.is_dirty = True
|
||||
self.app.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
|
||||
|
||||
def edit_sector(self, sector_id: str) -> None:
|
||||
sect = self.app.model.get_sector(sector_id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue