-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1878 from riganti/bug/postbackhandler-binding-tra…
…nslation Binding translation issue in PostBackHandler properties
- Loading branch information
Showing
13 changed files
with
386 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/Samples/Common/ViewModels/FeatureSamples/PostBack/PostBackHandlerBindingViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using DotVVM.Framework.ViewModel; | ||
using DotVVM.Framework.Hosting; | ||
|
||
namespace DotVVM.Samples.Common.ViewModels.FeatureSamples.PostBack | ||
{ | ||
public class PostBackHandlerBindingViewModel : DotvvmViewModelBase | ||
{ | ||
public bool Enabled { get; set; } = false; | ||
|
||
public int Counter { get; set; } = 0; | ||
|
||
public string[] Items { get; set; } = new string[] { "Item 1", "Item 2", "Item 3" }; | ||
} | ||
} | ||
|
35 changes: 35 additions & 0 deletions
35
src/Samples/Common/Views/FeatureSamples/PostBack/PostBackHandlerBinding.dothtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@viewModel DotVVM.Samples.Common.ViewModels.FeatureSamples.PostBack.PostBackHandlerBindingViewModel, DotVVM.Samples.Common | ||
|
||
<!DOCTYPE html> | ||
|
||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title></title> | ||
</head> | ||
<body> | ||
|
||
<p> | ||
<dot:CheckBox Text="Suppress postbacks" Checked="{value: Enabled}" /> | ||
</p> | ||
<p>Counter: <span class="result">{{value: Counter}}</span></p> | ||
|
||
<p>Click on grid rows to increment the counter.</p> | ||
|
||
<dot:GridView DataSource="{value: Items}"> | ||
<Columns> | ||
<dot:GridViewTextColumn HeaderText="Column 1" ValueBinding="{value: _this}" /> | ||
</Columns> | ||
<RowDecorators> | ||
<dot:Decorator Events.Click="{command: _parent.Counter = _parent.Counter + 1}" style="cursor: pointer"> | ||
<PostBack.Handlers> | ||
<dot:SuppressPostBackHandler Suppress="{value: _parent.Enabled}" /> | ||
</PostBack.Handlers> | ||
</dot:Decorator> | ||
</RowDecorators> | ||
</dot:GridView> | ||
|
||
</body> | ||
</html> | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Globalization; | ||
using System.Threading.Tasks; | ||
using CheckTestOutput; | ||
using DotVVM.Framework.Compilation; | ||
using DotVVM.Framework.Controls; | ||
using DotVVM.Framework.Tests.Binding; | ||
using DotVVM.Framework.ViewModel; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using DotVVM.Framework.Testing; | ||
using System.Security.Claims; | ||
using System.Collections; | ||
using DotVVM.Framework.Binding; | ||
using DotVVM.Framework.Compilation.ControlTree; | ||
using DotVVM.Framework.Hosting; | ||
|
||
namespace DotVVM.Framework.Tests.ControlTests | ||
{ | ||
[TestClass] | ||
public class PostbackHandlerTests | ||
{ | ||
static readonly ControlTestHelper cth = new ControlTestHelper(config: config => { | ||
}); | ||
readonly OutputChecker check = new OutputChecker("testoutputs"); | ||
|
||
|
||
[TestMethod] | ||
public async Task ButtonHandlers() | ||
{ | ||
var r = await cth.RunPage(typeof(BasicTestViewModel), """ | ||
<!-- suppress postback --> | ||
<dot:Button DataContext={value: Nested} Click={staticCommand: 0} Text="Test supress"> | ||
<Postback.Handlers> | ||
<dot:SuppressPostBackHandler Suppress={value: _parent.Integer > 100} /> | ||
<dot:SuppressPostBackHandler Suppress={value: SomeString.Length < 5} /> | ||
</Postback.Handlers> | ||
</dot:Button> | ||
<!-- confirm --> | ||
<dot:Button DataContext={value: Nested} Click={staticCommand: 0} Text="Test confirm"> | ||
<Postback.Handlers> | ||
<dot:ConfirmPostBackHandler Message={value: $"String={_root.String} SomeString={SomeString}"} /> | ||
</Postback.Handlers> | ||
</dot:Button> | ||
""" | ||
); | ||
|
||
check.CheckString(r.FormattedHtml, fileExtension: "html"); | ||
} | ||
|
||
public class BasicTestViewModel: DotvvmViewModelBase | ||
{ | ||
public int Integer { get; set; } = 123; | ||
public bool Boolean { get; set; } = false; | ||
public string String { get; set; } = "some-string"; | ||
|
||
public TestViewModel3 Nested { get; set; } = new TestViewModel3 { SomeString = "a" }; | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/Tests/ControlTests/testoutputs/PostbackHandlerTests.ButtonHandlers.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<html> | ||
<head></head> | ||
<body> | ||
|
||
<!-- suppress postback --> | ||
<!-- ko with: Nested --> | ||
<input onclick="dotvvm.applyPostbackHandlers((options) => { | ||
0; | ||
},this,[["suppress",(c,d)=>({suppress:c.$parent.Integer() > 100})],["suppress",(c,d)=>({suppress:d.SomeString()?.length < 5})]]).catch(dotvvm.log.logPostBackScriptError);event.stopPropagation();return false;" type="button" value="Test supress"> | ||
<!-- /ko --> | ||
<!-- confirm --> | ||
<!-- ko with: Nested --> | ||
<input onclick="dotvvm.applyPostbackHandlers((options) => { | ||
0; | ||
},this,[["confirm",(c,d)=>({message:dotvvm.translations.string.format("String={0} SomeString={1}", [ | ||
c.$parent.String() | ||
, d.SomeString() | ||
])})]]).catch(dotvvm.log.logPostBackScriptError);event.stopPropagation();return false;" type="button" value="Test confirm"> | ||
<!-- /ko --> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.