diff options
| author | Jason Lepp <jlepp@arcresources.com> | 2010-10-18 11:42:52 -0600 |
|---|---|---|
| committer | Jason Lepp <jlepp@arcresources.com> | 2010-10-18 11:42:52 -0600 |
| commit | ba82974e3873824e381004beb648f53ea8873933 (patch) | |
| tree | 620aea5da5ab3618b4706b77d7a3bc037a537178 | |
| parent | 62373c895f74937b5fdc086c1b68a82959796c15 (diff) | |
Add tooltips for validation errors. Fix Bootstrapper.
| -rwxr-xr-x | src/MVPtoMVVM.mvp/Bootstrap.cs | 2 | ||||
| -rwxr-xr-x | src/MVPtoMVVM.mvp/TodoItemView.xaml.cs | 11 | ||||
| -rw-r--r-- | src/MVPtoMVVM.mvp/presenters/TodoItemPresenter.cs | 12 | ||||
| -rw-r--r-- | src/MVPtoMVVM.mvp/views/ITodoItemView.cs | 2 | ||||
| -rwxr-xr-x | src/MVPtoMVVM.test/mvp/BootStrapperTest.cs | 3 |
5 files changed, 28 insertions, 2 deletions
diff --git a/src/MVPtoMVVM.mvp/Bootstrap.cs b/src/MVPtoMVVM.mvp/Bootstrap.cs index df0cb86..7ac8745 100755 --- a/src/MVPtoMVVM.mvp/Bootstrap.cs +++ b/src/MVPtoMVVM.mvp/Bootstrap.cs @@ -1,4 +1,5 @@ using MVPtoMVVM.domain;
+using MVPtoMVVM.presenters;
using StructureMap;
namespace MVPtoMVVM.mvp
@@ -11,6 +12,7 @@ namespace MVPtoMVVM.mvp x.Scan(scanner =>
{
scanner.AssemblyContainingType(typeof(TodoItem));
+ scanner.AssemblyContainingType(typeof(TodoItemPresenter));
scanner.WithDefaultConventions();
})
);
diff --git a/src/MVPtoMVVM.mvp/TodoItemView.xaml.cs b/src/MVPtoMVVM.mvp/TodoItemView.xaml.cs index 7325412..e030379 100755 --- a/src/MVPtoMVVM.mvp/TodoItemView.xaml.cs +++ b/src/MVPtoMVVM.mvp/TodoItemView.xaml.cs @@ -1,6 +1,5 @@ using System;
using System.Windows;
-using System.Windows.Controls;
using System.Windows.Media;
using MVPtoMVVM.presenters;
using MVPtoMVVM.views;
@@ -91,6 +90,16 @@ namespace MVPtoMVVM.mvp set { dueSoonAlert.Visibility = value ? Visibility.Visible : Visibility.Hidden; }
}
+ public string DescriptionValidationMessage
+ {
+ set { description.ToolTip = value; }
+ }
+
+ public string DueDateValidationMessage
+ {
+ set { dueDate.ToolTip = value; }
+ }
+
public void Remove(int itemId)
{
parent.Remove(itemId);
diff --git a/src/MVPtoMVVM.mvp/presenters/TodoItemPresenter.cs b/src/MVPtoMVVM.mvp/presenters/TodoItemPresenter.cs index 6a9eb13..7e1d6d5 100644 --- a/src/MVPtoMVVM.mvp/presenters/TodoItemPresenter.cs +++ b/src/MVPtoMVVM.mvp/presenters/TodoItemPresenter.cs @@ -88,7 +88,9 @@ namespace MVPtoMVVM.presenters {
view.SaveButtonEnabled = IsDirty && IsDescriptionValid() && IsDueDateValid();
view.DescriptionHasValidationErrors = !IsDescriptionValid();
+ view.DescriptionValidationMessage = GetDescriptionValidationMessage();
view.DueDateHasValidationErrors = !IsDueDateValid();
+ view.DueDateValidationMessage = GetDueDateValidationMessage();
view.IsDueSoon = IsDueSoon();
}
@@ -106,5 +108,15 @@ namespace MVPtoMVVM.presenters {
return dueDate <= DateTime.Today.AddDays(1);
}
+
+ private string GetDescriptionValidationMessage()
+ {
+ return IsDescriptionValid() ? null : "You must enter a description";
+ }
+
+ private string GetDueDateValidationMessage()
+ {
+ return IsDueDateValid() ? null : "Due Date must be today or later";
+ }
}
}
\ No newline at end of file diff --git a/src/MVPtoMVVM.mvp/views/ITodoItemView.cs b/src/MVPtoMVVM.mvp/views/ITodoItemView.cs index 4813ddd..14e4100 100644 --- a/src/MVPtoMVVM.mvp/views/ITodoItemView.cs +++ b/src/MVPtoMVVM.mvp/views/ITodoItemView.cs @@ -14,6 +14,8 @@ namespace MVPtoMVVM.views bool DescriptionHasValidationErrors { set; }
bool DueDateHasValidationErrors { set; }
bool IsDueSoon { set; }
+ string DescriptionValidationMessage { set; }
+ string DueDateValidationMessage { set; }
void Remove(int itemId);
}
}
\ No newline at end of file diff --git a/src/MVPtoMVVM.test/mvp/BootStrapperTest.cs b/src/MVPtoMVVM.test/mvp/BootStrapperTest.cs index 5a5a150..400e9f4 100755 --- a/src/MVPtoMVVM.test/mvp/BootStrapperTest.cs +++ b/src/MVPtoMVVM.test/mvp/BootStrapperTest.cs @@ -1,3 +1,4 @@ +using System;
using MVPtoMVVM.mvp;
using MVPtoMVVM.repositories;
using NUnit.Framework;
@@ -18,7 +19,7 @@ namespace MVPtoMVVM.test.mvp [Test]
public void it_should_register_the_repository()
{
- ObjectFactory.WhatDoIHave();
+ Console.Out.WriteLine(ObjectFactory.WhatDoIHave());
Assert.That(ObjectFactory.GetInstance<ITodoItemRepository>(), Is.TypeOf<TodoItemRepository>());
}
}
|
