Browse Source

Disable master page and content placeholder id controls when partial view is selected in Add MVC View dialog.

pull/18/head
Matt Ward 14 years ago
parent
commit
0504ca83bb
  1. 16
      src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/AddMvcViewToProjectView.xaml
  2. 15
      src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/AddMvcViewToProjectViewModel.cs
  3. 95
      src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/AddMvcViewToProjectViewModelTests.cs

16
src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/AddMvcViewToProjectView.xaml

@ -113,39 +113,42 @@
<Label <Label
Grid.Row="6" Grid.Row="6"
Margin="0, 20, 0, 0" Margin="0, 20, 0, 0"
IsEnabled="{Binding Path=IsContentPageEnabled}"
Visibility="{Binding Path=IsAspxViewEngineSelected, Converter={StaticResource BoolToVisibility}}" Visibility="{Binding Path=IsAspxViewEngineSelected, Converter={StaticResource BoolToVisibility}}"
Content="Use Master Page:"/> Content="Use Master Page:"/>
<Label <Label
Grid.Row="6" Grid.Row="6"
Margin="0, 20, 0, 0" Margin="0, 20, 0, 0"
IsEnabled="{Binding Path=IsContentPageEnabled}"
Visibility="{Binding Path=IsRazorViewEngineSelected, Converter={StaticResource BoolToVisibility}}" Visibility="{Binding Path=IsRazorViewEngineSelected, Converter={StaticResource BoolToVisibility}}"
Content="Use Layout:"/> Content="Use Layout:"/>
<CheckBox <CheckBox
Grid.Column="1" Grid.Column="1"
Grid.Row="6" Grid.Row="6"
Margin="0, 28, 0, 0" Margin="0, 28, 0, 0"
IsEnabled="{Binding Path=IsContentPageEnabled}"
IsChecked="{Binding Path=IsContentPage}"/> IsChecked="{Binding Path=IsContentPage}"/>
<Label <Label
Grid.Row="7" Grid.Row="7"
Visibility="{Binding Path=IsAspxViewEngineSelected, Converter={StaticResource BoolToVisibility}}" Visibility="{Binding Path=IsAspxViewEngineSelected, Converter={StaticResource BoolToVisibility}}"
IsEnabled="{Binding Path=IsContentPage}" IsEnabled="{Binding Path=IsContentPagePropertiesEnabled}"
Content="Master Page:"/> Content="Master Page:"/>
<Label <Label
Grid.Row="7" Grid.Row="7"
Visibility="{Binding Path=IsRazorViewEngineSelected, Converter={StaticResource BoolToVisibility}}" Visibility="{Binding Path=IsRazorViewEngineSelected, Converter={StaticResource BoolToVisibility}}"
IsEnabled="{Binding Path=IsContentPage}" IsEnabled="{Binding Path=IsContentPagePropertiesEnabled}"
Content="Layout:"/> Content="Layout:"/>
<Grid <Grid
Grid.Row="7" Grid.Row="7"
Grid.Column="1"> Grid.Column="1"
IsEnabled="{Binding Path=IsContentPagePropertiesEnabled}">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBox <TextBox
IsEnabled="{Binding Path=IsContentPage}"
Text="{Binding Path=MasterPageFile}"/> Text="{Binding Path=MasterPageFile}"/>
<StackPanel <StackPanel
Grid.Column="2" Grid.Column="2"
@ -153,7 +156,6 @@
<Button <Button
Padding="9, 0, 9, 0" Padding="9, 0, 9, 0"
Style="{x:Null}" Style="{x:Null}"
IsEnabled="{Binding Path=IsContentPage}"
Content="..." Content="..."
Command="{Binding Path=OpenSelectMasterPageViewCommand}"/> Command="{Binding Path=OpenSelectMasterPageViewCommand}"/>
</StackPanel> </StackPanel>
@ -162,13 +164,13 @@
<Label <Label
Grid.Row="8" Grid.Row="8"
Visibility="{Binding Path=IsAspxViewEngineSelected, Converter={StaticResource BoolToVisibility}}" Visibility="{Binding Path=IsAspxViewEngineSelected, Converter={StaticResource BoolToVisibility}}"
IsEnabled="{Binding Path=IsContentPage}" IsEnabled="{Binding Path=IsContentPagePropertiesEnabled}"
Content="Main Content ID:"/> Content="Main Content ID:"/>
<TextBox <TextBox
Grid.Row="8" Grid.Row="8"
Grid.Column="1" Grid.Column="1"
Visibility="{Binding Path=IsAspxViewEngineSelected, Converter={StaticResource BoolToVisibility}}" Visibility="{Binding Path=IsAspxViewEngineSelected, Converter={StaticResource BoolToVisibility}}"
IsEnabled="{Binding Path=IsContentPage}" IsEnabled="{Binding Path=IsContentPagePropertiesEnabled}"
Text="{Binding Path=PrimaryContentPlaceHolderId}"/> Text="{Binding Path=PrimaryContentPlaceHolderId}"/>
<StackPanel <StackPanel

15
src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/AddMvcViewToProjectViewModel.cs

@ -203,9 +203,18 @@ namespace ICSharpCode.AspNet.Mvc
set { set {
isContentPage = value; isContentPage = value;
OnPropertyChanged(viewModel => viewModel.IsContentPage); OnPropertyChanged(viewModel => viewModel.IsContentPage);
OnPropertyChanged(viewModel => viewModel.IsContentPagePropertiesEnabled);
} }
} }
public bool IsContentPageEnabled {
get { return !IsPartialView; }
}
public bool IsContentPagePropertiesEnabled {
get { return IsContentPage && IsContentPageEnabled; }
}
public bool CanAddMvcView() public bool CanAddMvcView()
{ {
return viewFileName.HasValidViewName(); return viewFileName.HasValidViewName();
@ -275,7 +284,11 @@ namespace ICSharpCode.AspNet.Mvc
public bool IsPartialView { public bool IsPartialView {
get { return viewFileName.IsPartialView; } get { return viewFileName.IsPartialView; }
set { viewFileName.IsPartialView = value; } set {
viewFileName.IsPartialView = value;
OnPropertyChanged(viewModel => viewModel.IsContentPageEnabled);
OnPropertyChanged(viewModel => viewModel.IsContentPagePropertiesEnabled);
}
} }
public bool IsStronglyTypedView { public bool IsStronglyTypedView {

95
src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/AddMvcViewToProjectViewModelTests.cs

@ -1148,5 +1148,100 @@ namespace AspNet.Mvc.Tests
Assert.IsTrue(fired); Assert.IsTrue(fired);
} }
[Test]
public void IsContentPageEnabled_IsPartialViewIsNotSelected_ReturnsTrue()
{
CreateViewModel();
viewModel.IsPartialView = false;
bool enabled = viewModel.IsContentPageEnabled;
Assert.IsTrue(enabled);
}
[Test]
public void IsContentPageEnabled_IsPartialViewIsSelected_ReturnsFalse()
{
CreateViewModel();
viewModel.IsPartialView = true;
bool enabled = viewModel.IsContentPageEnabled;
Assert.IsFalse(enabled);
}
[Test]
public void IsPartialView_IsPartialViewChangedFromTrueToFalse_IsContentPageEnabledPropertyChangedEventIsFired()
{
CreateViewModel();
viewModel.IsPartialView = true;
MonitorPropertyChangedEvents();
viewModel.IsPartialView = false;
SelectRazorViewEngine();
bool fired = propertyChangedEvents.Contains("IsContentPageEnabled");
Assert.IsTrue(fired);
}
[Test]
public void IsContentPagePropertiesEnabled_IsPartialViewIsNotSelectedAndIsContentPageIsSelected_ReturnsTrue()
{
CreateViewModel();
viewModel.IsPartialView = false;
viewModel.IsContentPage = true;
bool enabled = viewModel.IsContentPagePropertiesEnabled;
Assert.IsTrue(enabled);
}
[Test]
public void IsContentPagePropertiesEnabled_IsPartialViewIsNotSelectedAndIsContentPageIsNotSelected_ReturnsFalse()
{
CreateViewModel();
viewModel.IsPartialView = false;
viewModel.IsContentPage = false;
bool enabled = viewModel.IsContentPagePropertiesEnabled;
Assert.IsFalse(enabled);
}
[Test]
public void IsContentPagePropertiesEnabled_IsPartialViewIsSelectedAndIsContentPageIsSelected_ReturnsFalse()
{
CreateViewModel();
viewModel.IsPartialView = true;
viewModel.IsContentPage = true;
bool enabled = viewModel.IsContentPagePropertiesEnabled;
Assert.IsFalse(enabled);
}
[Test]
public void IsPartialView_IsPartialViewChangedFromTrueToFalse_IsContentPagePropertiesEnabledPropertyChangedEventIsFired()
{
CreateViewModel();
viewModel.IsPartialView = true;
MonitorPropertyChangedEvents();
viewModel.IsPartialView = false;
SelectRazorViewEngine();
bool fired = propertyChangedEvents.Contains("IsContentPagePropertiesEnabled");
Assert.IsTrue(fired);
}
[Test]
public void IsPartialView_IsContentPageChangedFromTrueToFalse_IsContentPagePropertiesEnabledPropertyChangedEventIsFired()
{
CreateViewModel();
viewModel.IsContentPage = true;
MonitorPropertyChangedEvents();
viewModel.IsContentPage = false;
SelectRazorViewEngine();
bool fired = propertyChangedEvents.Contains("IsContentPagePropertiesEnabled");
Assert.IsTrue(fired);
}
} }
} }

Loading…
Cancel
Save