| | | 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="FirstName"> |
| | | 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" placeh |
| | | 16 | | <span class="input-group-btn"> |
| | | 17 | | <button id="btnClearSQLBuilder" name="btnClearSQLBuilder" class="btn btn-danger" @onclick="Clear"><i |
| | | 18 | | </span> |
| | | 19 | | </div> |
| | | 20 | | </div> |
| | | 21 | | </div> |
| | | 22 | | <div class="row"> |
| | | 23 | | <div class="col"> |
| | | 24 | | <div class="form-check"> |
| | | 25 | | <input class="form-check-input" type="checkbox" id="chkIncludeWildcard" @bind-value="IncludeWildcard" ch |
| | | 26 | | <label class="form-check-label" for="chkIncludeWildcard"> |
| | | 27 | | Include Wildcard |
| | | 28 | | </label> |
| | | 29 | | </div> |
| | | 30 | | </div> |
| | | 31 | | </div> |
| | | 32 | | <div class="row"> |
| | | 33 | | <div class="col"> |
| | | 34 | | <button class="btn btn-success" type="button" id="btnParse" name="btnParse" @onclick="Create">Create</button |
| | | 35 | | </div> |
| | | 36 | | </div> |
| | | 37 | | <div class="row"> |
| | | 38 | | <div class="col"> |
| | | 39 | | <div class="input-group"> |
| | | 40 | | <textarea id="sqlBuilderOutput" name="sqlBuilderOutput" class="form-control" rows="5" @bind="Output" pla |
| | | 41 | | <span class="input-group-btn"> |
| | | 42 | | <button id="btnCopySQLBuilder" name="btnCopySQLBuilder" class="btn btn-info" @onclick="Copy"><i clas |
| | | 43 | | </span> |
| | | 44 | | </div> |
| | | 45 | | |
| | | 46 | | </div> |
| | | 47 | | </div> |
| | | 48 | | </div> |
| | | 49 | | |
| | | 50 | | @code { |
| | | 51 | | |
| | | 52 | | [Parameter] |
| | 22 | 53 | | public string? Field { get; set; } = string.Empty; |
| | | 54 | | |
| | | 55 | | [Parameter] |
| | 18 | 56 | | public string? Input { get; set; } = string.Empty; |
| | | 57 | | |
| | | 58 | | [Parameter] |
| | 18 | 59 | | public string? Output { get; set; } = string.Empty; |
| | | 60 | | |
| | | 61 | | [Parameter] |
| | 22 | 62 | | public bool IncludeWildcard { get; set; } = false; |
| | | 63 | | |
| | 2 | 64 | | string wildcard = "*"; |
| | | 65 | | |
| | | 66 | | protected override void OnInitialized() |
| | 2 | 67 | | { |
| | | 68 | | // Field = string.Empty; |
| | | 69 | | // Input = string.Empty; |
| | | 70 | | // Output = string.Empty; |
| | 2 | 71 | | IncludeWildcard = false; |
| | 2 | 72 | | } |
| | | 73 | | |
| | | 74 | | async Task CopyField() |
| | 0 | 75 | | { |
| | 0 | 76 | | await JSRuntime.InvokeVoidAsync("navigator.clipboard.writeText", Field); |
| | 0 | 77 | | } |
| | | 78 | | |
| | | 79 | | private void ClearField() |
| | 0 | 80 | | { |
| | 0 | 81 | | Field = string.Empty; |
| | 0 | 82 | | } |
| | | 83 | | |
| | | 84 | | private void Clear() |
| | 0 | 85 | | { |
| | 0 | 86 | | Input = string.Empty; |
| | 0 | 87 | | } |
| | | 88 | | |
| | | 89 | | private void Create() |
| | 2 | 90 | | { |
| | | 91 | | // CONTAINS(Description, @SearchWord) |
| | | 92 | | // WHERE CONTAINS(t.something, '"bla*" OR "foo*" OR "batz*"') |
| | | 93 | | |
| | 2 | 94 | | var likeItems = ""; |
| | 2 | 95 | | wildcard = IncludeWildcard ? "*" : ""; |
| | | 96 | | |
| | 2 | 97 | | var items = Input.Split(new[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); |
| | 2 | 98 | | if (items.Length != 0) |
| | 2 | 99 | | { |
| | 8 | 100 | | likeItems = string.Join(" OR ", items.Select(i => $"CONTAINS ({Field}, '{wildcard}{i.Trim()}{wildcard}')")); |
| | 2 | 101 | | } |
| | | 102 | | |
| | 2 | 103 | | Output = likeItems; |
| | 2 | 104 | | } |
| | | 105 | | |
| | | 106 | | async Task Copy() |
| | 0 | 107 | | { |
| | 0 | 108 | | await JSRuntime.InvokeVoidAsync("navigator.clipboard.writeText", Output); |
| | 0 | 109 | | } |
| | | 110 | | } |