allow read-only views of not-assigned participants of any data
This commit is contained in:
parent
ebfa7c1fc7
commit
02705f2677
@ -44,6 +44,23 @@ namespace BreCalClient
|
||||
|
||||
this.comboBoxArrivalBerth.ItemsSource = BreCalLists.Berths;
|
||||
this.CopyToControls();
|
||||
|
||||
|
||||
Participant? p = null;
|
||||
if(this.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY))
|
||||
p = BreCalLists.Participants.Find(x => x.Id == this.ShipcallModel.AssignedParticipants[ParticipantType.AGENCY].ParticipantId);
|
||||
|
||||
bool allowBSMD = false;
|
||||
if (p != null)
|
||||
{
|
||||
allowBSMD = p.IsFlagSet(ParticipantFlag.ALLOW_BSMD);
|
||||
}
|
||||
|
||||
bool enableControls = (this.Times.ParticipantId == App.Participant.Id) ||
|
||||
(App.Participant.IsTypeFlagSet(ParticipantType.BSMD) && allowBSMD);
|
||||
|
||||
this.EnableControls(enableControls);
|
||||
|
||||
}
|
||||
|
||||
private void buttonOK_Click(object sender, RoutedEventArgs e)
|
||||
@ -220,6 +237,32 @@ namespace BreCalClient
|
||||
}
|
||||
}
|
||||
|
||||
private void EnableControls(bool isEnabled)
|
||||
{
|
||||
this.datePickerETA.IsEnabled = isEnabled;
|
||||
this.comboBoxArrivalBerth.IsEnabled = isEnabled;
|
||||
this.comboBoxPierside.IsEnabled = isEnabled;
|
||||
this.textBoxBerthRemarks.IsEnabled = isEnabled;
|
||||
this.doubleUpDownDraft.IsEnabled = isEnabled;
|
||||
this.datePickerTidalWindowFrom.IsEnabled = isEnabled;
|
||||
this.datePickerTidalWindowTo.IsEnabled = isEnabled;
|
||||
this.checkBoxCanceled.IsEnabled = isEnabled;
|
||||
|
||||
this.checkBoxAnchored.IsEnabled = isEnabled;
|
||||
this.checkBoxTugRequired.IsEnabled = isEnabled;
|
||||
this.comboBoxTug.IsEnabled = isEnabled;
|
||||
this.integerUpDownRecommendedTugs.IsEnabled = isEnabled;
|
||||
this.checkBoxPilotRequired.IsEnabled = isEnabled;
|
||||
this.comboBoxPilot.IsEnabled = isEnabled;
|
||||
this.comboBoxMooring.IsEnabled = isEnabled;
|
||||
this.checkBoxMooredLock.IsEnabled = isEnabled;
|
||||
this.comboBoxTerminal.IsEnabled = isEnabled;
|
||||
this.checkBoxBunkering.IsEnabled = isEnabled;
|
||||
this.checkBoxReplenishingTerminal.IsEnabled = isEnabled;
|
||||
this.checkBoxReplenishingLock.IsEnabled = isEnabled;
|
||||
this.textBoxRemarks.IsEnabled = isEnabled;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region context menu handlers
|
||||
|
||||
@ -45,6 +45,22 @@ namespace BreCalClient
|
||||
|
||||
this.comboBoxDepartureBerth.ItemsSource = BreCalLists.Berths;
|
||||
this.CopyToControls();
|
||||
|
||||
Participant? p = null;
|
||||
if (this.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY))
|
||||
p = BreCalLists.Participants.Find(x => x.Id == this.ShipcallModel.AssignedParticipants[ParticipantType.AGENCY].ParticipantId);
|
||||
|
||||
bool allowBSMD = false;
|
||||
if (p != null)
|
||||
{
|
||||
allowBSMD = p.IsFlagSet(ParticipantFlag.ALLOW_BSMD);
|
||||
}
|
||||
|
||||
bool enableControls = (this.Times.ParticipantId == App.Participant.Id) ||
|
||||
(App.Participant.IsTypeFlagSet(ParticipantType.BSMD) && allowBSMD);
|
||||
|
||||
this.EnableControls(enableControls);
|
||||
|
||||
}
|
||||
|
||||
private void buttonOK_Click(object sender, RoutedEventArgs e)
|
||||
@ -210,6 +226,29 @@ namespace BreCalClient
|
||||
}
|
||||
}
|
||||
|
||||
private void EnableControls(bool isEnabled)
|
||||
{
|
||||
this.datePickerETD.IsEnabled = isEnabled;
|
||||
this.comboBoxDepartureBerth.IsEnabled = isEnabled;
|
||||
this.comboBoxPierside.IsEnabled = isEnabled;
|
||||
this.textBoxBerthRemarks.IsEnabled = isEnabled;
|
||||
this.doubleUpDownDraft.IsEnabled = isEnabled;
|
||||
this.datePickerTidalWindowFrom.IsEnabled = isEnabled;
|
||||
this.datePickerTidalWindowTo.IsEnabled = isEnabled;
|
||||
this.checkBoxCanceled.IsEnabled = isEnabled;
|
||||
|
||||
this.checkBoxTugRequired.IsEnabled = isEnabled;
|
||||
this.comboBoxTug.IsEnabled = isEnabled;
|
||||
this.integerUpDownRecommendedTugs.IsEnabled = isEnabled;
|
||||
this.checkBoxPilotRequired.IsEnabled = isEnabled;
|
||||
this.comboBoxPilot.IsEnabled = isEnabled;
|
||||
this.comboBoxMooring.IsEnabled = isEnabled;
|
||||
this.checkBoxMooredLock.IsEnabled = isEnabled;
|
||||
this.comboBoxTerminal.IsEnabled = isEnabled;
|
||||
this.checkBoxRainsensitiveCargo.IsEnabled = isEnabled;
|
||||
this.textBoxRemarks.IsEnabled = isEnabled;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region context menu handlers
|
||||
|
||||
@ -46,6 +46,22 @@ namespace BreCalClient
|
||||
this.comboBoxDepartureBerth.ItemsSource = BreCalLists.Berths;
|
||||
this.comboBoxArrivalBerth.ItemsSource = BreCalLists.Berths;
|
||||
this.CopyToControls();
|
||||
|
||||
Participant? p = null;
|
||||
if (this.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY))
|
||||
p = BreCalLists.Participants.Find(x => x.Id == this.ShipcallModel.AssignedParticipants[ParticipantType.AGENCY].ParticipantId);
|
||||
|
||||
bool allowBSMD = false;
|
||||
if (p != null)
|
||||
{
|
||||
allowBSMD = p.IsFlagSet(ParticipantFlag.ALLOW_BSMD);
|
||||
}
|
||||
|
||||
bool enableControls = (this.Times.ParticipantId == App.Participant.Id) ||
|
||||
(App.Participant.IsTypeFlagSet(ParticipantType.BSMD) && allowBSMD);
|
||||
|
||||
this.EnableControls(enableControls);
|
||||
|
||||
}
|
||||
|
||||
private void buttonOK_Click(object sender, RoutedEventArgs e)
|
||||
@ -226,6 +242,31 @@ namespace BreCalClient
|
||||
}
|
||||
}
|
||||
|
||||
private void EnableControls(bool isEnabled)
|
||||
{
|
||||
this.datePickerETD.IsEnabled = isEnabled;
|
||||
this.comboBoxArrivalBerth.IsEnabled = isEnabled;
|
||||
this.doubleUpDownDraft.IsEnabled = isEnabled;
|
||||
this.datePickerTidalWindowFrom.IsEnabled = isEnabled;
|
||||
this.datePickerTidalWindowTo.IsEnabled = isEnabled;
|
||||
this.datePickerETA.IsEnabled = isEnabled;
|
||||
this.comboBoxDepartureBerth.IsEnabled = isEnabled;
|
||||
this.comboBoxPiersideArrival.IsEnabled = isEnabled;
|
||||
this.textBoxBerthRemarksArrival.IsEnabled = isEnabled;
|
||||
this.checkBoxCanceled.IsEnabled = isEnabled;
|
||||
|
||||
this.checkBoxTugRequired.IsEnabled = isEnabled;
|
||||
this.comboBoxTug.IsEnabled = isEnabled;
|
||||
this.integerUpDownRecommendedTugs.IsEnabled = isEnabled;
|
||||
this.checkBoxPilotRequired.IsEnabled = isEnabled;
|
||||
this.comboBoxPilot.IsEnabled = isEnabled;
|
||||
this.comboBoxMooring.IsEnabled = isEnabled;
|
||||
this.checkBoxMooredLock.IsEnabled = isEnabled;
|
||||
this.comboBoxTerminal.IsEnabled = isEnabled;
|
||||
this.checkBoxRainsensitiveCargo.IsEnabled = isEnabled;
|
||||
this.textBoxRemarks.IsEnabled = isEnabled;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region context menu handlers
|
||||
|
||||
@ -36,26 +36,19 @@ namespace BreCalClient
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.CopyToControls();
|
||||
// enable controls according to participant type
|
||||
this.datePickerETABerth.IsEnabled = App.Participant.IsTypeFlagSet(Extensions.ParticipantType.AGENCY) ||
|
||||
App.Participant.IsTypeFlagSet(Extensions.ParticipantType.MOORING) ||
|
||||
App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PILOT) ||
|
||||
App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PORT_ADMINISTRATION) ||
|
||||
App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TUG);
|
||||
bool enableControls = this.Times.ParticipantId == App.Participant.Id;
|
||||
|
||||
this.datePickerETABerth.IsEnabled = enableControls;
|
||||
this.checkBoxEtaBerthFixed.IsEnabled = enableControls;
|
||||
this.datePickerETDBerth.IsEnabled = enableControls;
|
||||
this.checkBoxEtDBerthFixed.IsEnabled = enableControls;
|
||||
this.datePickerLockTime.IsEnabled = enableControls;
|
||||
this.checkBoxLockTimeFixed.IsEnabled = enableControls;
|
||||
this.datePickerZoneEntry.IsEnabled = enableControls;
|
||||
this.checkBoxZoneEntryFixed.IsEnabled = enableControls;
|
||||
this.textBoxRemarks.IsEnabled = enableControls;
|
||||
this.buttonOK.IsEnabled = enableControls;
|
||||
|
||||
this.checkBoxEtaBerthFixed.IsEnabled = this.datePickerETABerth.IsEnabled;
|
||||
this.datePickerETDBerth.IsEnabled = this.datePickerETABerth.IsEnabled;
|
||||
this.checkBoxEtDBerthFixed.IsEnabled = this.datePickerETABerth.IsEnabled;
|
||||
|
||||
this.datePickerLockTime.IsEnabled = App.Participant.IsTypeFlagSet(Extensions.ParticipantType.AGENCY) ||
|
||||
App.Participant.IsTypeFlagSet(Extensions.ParticipantType.MOORING) ||
|
||||
App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PORT_ADMINISTRATION);
|
||||
this.checkBoxLockTimeFixed.IsEnabled = this.datePickerLockTime.IsEnabled;
|
||||
|
||||
this.datePickerZoneEntry.IsEnabled = App.Participant.IsTypeFlagSet(Extensions.ParticipantType.AGENCY) ||
|
||||
App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PILOT);
|
||||
this.checkBoxZoneEntryFixed.IsEnabled = this.datePickerZoneEntry.IsEnabled;
|
||||
}
|
||||
|
||||
private void buttonOK_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
@ -29,6 +29,15 @@ namespace BreCalClient
|
||||
{
|
||||
this.comboBoxBerth.ItemsSource = BreCalLists.Berths;
|
||||
this.CopyToControls();
|
||||
|
||||
bool enableControls = this.Times.ParticipantId == App.Participant.Id;
|
||||
this.datePickerOperationStart.IsEnabled = enableControls;
|
||||
this.datePickerOperationEnd.IsEnabled = enableControls;
|
||||
this.comboBoxBerth.IsEnabled = enableControls;
|
||||
this.comboBoxPierside.IsEnabled = enableControls;
|
||||
this.textBoxRemarks.IsEnabled = enableControls;
|
||||
this.textBoxBerthRemarks.IsEnabled = enableControls;
|
||||
this.buttonOK.IsEnabled = enableControls;
|
||||
}
|
||||
|
||||
private void contextMenuItemClearOperationStart_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
@ -560,15 +560,27 @@ namespace BreCalClient
|
||||
|
||||
private async void Sc_EditTimesRequested(ShipcallControl obj, Times? times, Extensions.ParticipantType participantType)
|
||||
{
|
||||
|
||||
if( obj.ShipcallControlModel == null) { return; }
|
||||
if (!obj.ShipcallControlModel.AssignedParticipants.ContainsKey(participantType)) return; // no assigment means no dialog my friend
|
||||
|
||||
// show a dialog that lets the user create / update times for the given shipcall
|
||||
IEditTimesControl etc = (participantType == ParticipantType.TERMINAL) ? new EditTimesTerminalControl() : new EditTimesControl();
|
||||
|
||||
|
||||
bool wasEdit = false;
|
||||
if (times != null)
|
||||
{
|
||||
etc.Times = times;
|
||||
wasEdit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(obj.ShipcallControlModel.AssignedParticipants[participantType].ParticipantId == App.Participant.Id)
|
||||
{
|
||||
etc.Times.ParticipantId = App.Participant.Id; // this is my record, so the Participant Id is set that allows editing
|
||||
}
|
||||
}
|
||||
|
||||
// actually we should only do this on create but we have existing data
|
||||
etc.Times.ParticipantType = (int) participantType;
|
||||
@ -631,8 +643,16 @@ namespace BreCalClient
|
||||
if(editControl.ShowDialog() ?? false)
|
||||
{
|
||||
try
|
||||
{
|
||||
// always try to be the agent, even if we are BSMD
|
||||
if (editControl.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY))
|
||||
{
|
||||
editControl.Times.ParticipantId = editControl.ShipcallModel.AssignedParticipants[ParticipantType.AGENCY].ParticipantId;
|
||||
}
|
||||
else
|
||||
{
|
||||
editControl.Times.ParticipantId = App.Participant.Id;
|
||||
}
|
||||
|
||||
if (wasEdit)
|
||||
{
|
||||
|
||||
@ -270,7 +270,7 @@ namespace BreCalClient
|
||||
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
// TBD
|
||||
}
|
||||
|
||||
private void buttonEditShipcall_Click(object? sender, RoutedEventArgs? e)
|
||||
@ -285,59 +285,40 @@ namespace BreCalClient
|
||||
}
|
||||
|
||||
private void labelAgent_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if ((App.Participant.IsTypeFlagSet(Extensions.ParticipantType.AGENCY) && (App.Participant.Id == _agency?.Id)) ||
|
||||
(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.BSMD) && (_agency != null) && _agency.IsFlagSet(Extensions.ParticipantFlag.ALLOW_BSMD)))
|
||||
{
|
||||
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.AGENCY);
|
||||
this.EditAgencyRequested?.Invoke(this, times);
|
||||
}
|
||||
}
|
||||
|
||||
private void labelMooring_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.MOORING) && (App.Participant.Id == _mooring?.Id))
|
||||
{
|
||||
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.MOORING);
|
||||
this.EditTimesRequested?.Invoke(this, times, Extensions.ParticipantType.MOORING);
|
||||
}
|
||||
}
|
||||
|
||||
private void labelPortAuthority_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PORT_ADMINISTRATION) && (App.Participant.Id == _port_administration?.Id))
|
||||
{
|
||||
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.PORT_ADMINISTRATION);
|
||||
this.EditTimesRequested?.Invoke(this, times, Extensions.ParticipantType.PORT_ADMINISTRATION);
|
||||
}
|
||||
}
|
||||
|
||||
private void labelPilot_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PILOT) && (App.Participant.Id == _pilot?.Id))
|
||||
{
|
||||
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.PILOT);
|
||||
this.EditTimesRequested?.Invoke(this, times, Extensions.ParticipantType.PILOT);
|
||||
}
|
||||
}
|
||||
|
||||
private void labelTug_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TUG) && (App.Participant.Id == _tug?.Id))
|
||||
{
|
||||
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.TUG);
|
||||
this.EditTimesRequested?.Invoke(this, times, Extensions.ParticipantType.TUG);
|
||||
}
|
||||
}
|
||||
|
||||
private void labelTerminal_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TERMINAL) && (App.Participant.Id == _terminal?.Id))
|
||||
{
|
||||
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.TERMINAL);
|
||||
this.EditTimesRequested?.Invoke(this, times, Extensions.ParticipantType.TERMINAL);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user