| | 1 | | @inject IJSRuntime JSRuntime |
| | 2 | |
|
| | 3 | | <div class="container"> |
| | 4 | | <label class="label-control">Field:</label> |
| | 5 | | <div class="input-group"> |
| | 6 | | <input type="text" id="field" name="field" class="form-control" @bind="Field">@*placeholder="i.[Guid]"*@ |
| | 7 | | <span class="input-group-btn"> |
| | 8 | | <button class="btn btn-info" type="button" id="btnFieldCopy" name="btnFieldCopy" @onclick="CopyField"><i cla |
| | 9 | | <button class="btn btn-danger" type="button" id="btnFieldClear" name="btnFieldClear" @onclick="ClearField">< |
| | 10 | | </span> |
| | 11 | | </div> |
| | 12 | | <div class="row"> |
| | 13 | | <div class="col"> |
| | 14 | | <div class="input-group"> |
| | 15 | | <textarea id="sqlBuilderInput" name="sqlBuilderInput" class="form-control" rows="5" @bind="Input"></text |
| | 16 | | <span class="input-group-btn"> |
| | 17 | | <button id="btnClearSQLBuilder" name="btnClearSQLBuilder" class="btn btn-danger" @onclick="Clear"><i |
| | 18 | | </span> |
| | 19 | | </div> |
| | 20 | |
|
| | 21 | | </div> |
| | 22 | | </div> |
| | 23 | | <div class="row"> |
| | 24 | | <div class="col"> |
| | 25 | | <button class="btn btn-success" type="button" id="btnParse" name="btnParse" @onclick="Parse">Parse</button> |
| | 26 | | </div> |
| | 27 | | </div> |
| | 28 | | <div class="row"> |
| | 29 | | <div class="col"> |
| | 30 | | <div class="input-group"> |
| | 31 | | <textarea id="sqlBuilderOutput" name="sqlBuilderOutput" class="form-control" rows="5" @bind="Output"></t |
| | 32 | | <span class="input-group-btn"> |
| | 33 | | <button id="btnCopySQLBuilder" name="btnCopySQLBuilder" class="btn btn-info" @onclick="Copy"><i clas |
| | 34 | | </span> |
| | 35 | | </div> |
| | 36 | |
|
| | 37 | | </div> |
| | 38 | | </div> |
| | 39 | | </div> |
| | 40 | |
|
| | 41 | | @code { |
| | 42 | |
|
| 0 | 43 | | string Field = string.Empty; |
| 0 | 44 | | string Input = string.Empty; |
| 0 | 45 | | string Output = string.Empty; |
| 0 | 46 | | string wildcard = "%"; |
| | 47 | |
|
| | 48 | | async Task CopyField() |
| 0 | 49 | | { |
| 0 | 50 | | await JSRuntime.InvokeVoidAsync("navigator.clipboard.writeText", Field); |
| 0 | 51 | | } |
| | 52 | |
|
| | 53 | | private void ClearField() |
| 0 | 54 | | { |
| 0 | 55 | | Field = string.Empty; |
| 0 | 56 | | } |
| | 57 | |
|
| | 58 | | private void Clear() |
| 0 | 59 | | { |
| 0 | 60 | | Input = string.Empty; |
| 0 | 61 | | } |
| | 62 | |
|
| | 63 | | private void Parse() |
| 0 | 64 | | { |
| 0 | 65 | | var items = Input.Split(new[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); |
| 0 | 66 | | var likeItems = string.Join(" OR ", items.Select(i => $"{Field} LIKE {wildcard}{i.Trim()}{wildcard}")); |
| | 67 | |
|
| 0 | 68 | | Output = likeItems; |
| 0 | 69 | | } |
| | 70 | |
|
| | 71 | | async Task Copy() |
| 0 | 72 | | { |
| 0 | 73 | | await JSRuntime.InvokeVoidAsync("navigator.clipboard.writeText", Output); |
| 0 | 74 | | } |
| | 75 | | } |