Advertisement
Guest User

Untitled

a guest
May 7th, 2025
6
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.97 KB | None | 0 0
  1. <!-- VM for ViewModel and DataTableModel Table {get; set;} in ViewModel class --->
  2. <table class="table-word">
  3. <thead>
  4. <tr>
  5. <th>&nbsp;</th>
  6. @foreach (var col in VM.Table.Cols)
  7. {
  8. <th class="col-header @col.ClassName">
  9. @col.Num //or col.Header col.Name etc.
  10. <div class="header-action" @onclick:stopPropagation>
  11. <FluentButton IconStart= @SharedIcons.ViewColumnImages
  12. Class="word-action-button"
  13. title="View column images"
  14. OnClick=@(() => col.ShowImageAsync()) />
  15. </div>
  16. </th>
  17. }
  18. <th style="min-width:100vw"/>
  19. </tr>
  20. </thead>
  21. <tbody>
  22. @foreach (var row in VM.Table.Rows)
  23. {
  24. <tr @key=row.Book.Code>
  25. <th class="row-edition @row.Book.ClassName">
  26. @row.Book.Year&nbsp;@row.Book.ShortCode
  27. </th>
  28. @foreach (var word in row.Words)
  29. {
  30. <td @key=word.WordIndex class="table-word-item @word.ClassName">
  31. <div title=@($"Page {word.PageNumber} Word {word.WordIndex}") @onclick=@(() => OnWordClicked(word))>
  32. @word.DisplayText
  33. </div>
  34. <div class="table-word-buttons" @onclick:stopPropagation>
  35. <FluentButton
  36. Class="table-word-button"
  37. title="Add Word"
  38. OnClick=@(() => OnWordAddClicked(word)) />
  39. <FluentButton
  40. Class="table-word-button"
  41. title="Edit Word"
  42. OnClick=@(() => OnWordEditClicked(word)) />
  43. </div>
  44. </td>
  45. }
  46. </tr>
  47. }
  48. </tbody>
  49. </table>
  50.  
  51. <style>
  52.  
  53. /*
  54. // Selector: .table-word
  55. // Selector: .table-word .col-header
  56. // Selector: .table-word .col-header .header-action
  57. */
  58. .table-word tr:nth-child(1) {
  59. /* Instead of 'word-table_first-cell' */
  60. }
  61.  
  62.  
  63. /* Buttons exist for interaction, no need add 'action' while naming it*/
  64. .table-word-buttons
  65. {
  66. display: none; /* or hidden */
  67. /* Main style area */
  68. }
  69.  
  70. .table-word-item:hover .table-word-buttons
  71. {
  72. display: block;
  73. /* Additional style changes */
  74. }
  75. </style>
  76.  
  77. @code
  78. {
  79. private virtual void OnWordClicked(WordReference word);
  80. private void OnWordEditClicked(WordReference word)
  81. {
  82. // DISPLAY MODAL
  83. // Like
  84. /*
  85. <div class="modal">
  86. <div class="modal-content">
  87. <span class="close" @onclick=@(() => CloseModal())>&times;</span>
  88. <p>Word: @word.DisplayText</p>
  89. <input type="text" value="@word.DisplayText" @bind="@word.DisplayText" />
  90. <button @onclick=@(() => SaveWord(word))>Save</button>
  91. </div>
  92. </div>
  93. */
  94. }
  95.  
  96. private void OnWordAddClicked(WordReference word)
  97. {
  98. // DISPLAY MODAL
  99. // Similar to OnWordEditClicked but for adding a new word
  100. /*
  101. <div class="modal">
  102. <div class="modal-content">
  103. <span class="close" @onclick=@(() => CloseModal())>&times;</span>
  104. <p>Add New Word:</p>
  105. <input type="text" value="@word.DisplayText" @bind="@word.DisplayText" />
  106. <button @onclick=@(() => SaveWord(word))>Save</button>
  107. </div>
  108. </div>
  109. */
  110. }
  111.  
  112. private void SaveWord(WordReference word)
  113. {
  114. // Save the word to the database or perform any other action
  115. // Just send to the ViewModel to save the word, the viewmodel will handle the logic if it is a new word or an existing one.
  116. // CloseModal();
  117. }
  118.  
  119. private void OpenModal(WordReference word)
  120. {
  121. // Open the modal for editing the word
  122. /*
  123. <div class="modal">
  124. <div class="modal-content">
  125. <span class="close" @onclick=@(() => CloseModal())>&times;</span>
  126. <p>Edit Word:</p>
  127. <input type="text" value="@word.DisplayText" @bind="@word.DisplayText" />
  128. <button @onclick=@(() => SaveWord(word))>Save</button>
  129. </div>
  130. </div>
  131. */
  132. }
  133. private void CloseModal()
  134. {
  135. // Close the modal
  136. }
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement