Worked out a better way to handle the phrases in the words table

This commit is contained in:
Leonard Smith 2021-05-05 20:26:21 -05:00
parent fb7c8f193b
commit 24fca6f8b9
5 changed files with 31 additions and 17 deletions

View File

@ -1,14 +1,7 @@
{{#each this.phraseWords as |pw|}} {{#each this.phraseWords as |pw|}}
{{#if pw.rootRow}} {{#if pw.rootRow}}
<tr class="{{this.selected}}" ...attributes> <Words::WordRow @model={{pw}} @rowspan={{this.rowCount}} />
<td rowspan="{{this.rowCount}}">{{pw.ulb}}</td>
<td>{{pw.greek}}</td>
<td>{{pw.morph}}</td>
</tr>
{{else}} {{else}}
<tr {{on "click" (fn this.select pw)}} class="{{this.selected}}" ...attributes> <Words::WordRow @model={{pw}} @isPartial={{true}} />
<td>{{pw.greek}}</td>
<td>{{pw.morph}}</td>
</tr>
{{/if}} {{/if}}
{{/each}} {{/each}}

View File

@ -1,7 +1,8 @@
import WordsWordRowComponent from "./word-row"; import Component from '@glimmer/component';
import { tracked } from "@glimmer/tracking"; import { tracked } from "@glimmer/tracking";
export default class WordsPhraseRowComponent extends WordsWordRowComponent {
export default class WordsPhraseRowComponent extends Component {
@tracked phraseWords = []; @tracked phraseWords = [];
constructor(...args) { constructor(...args) {

View File

@ -1,5 +1,15 @@
<tr {{on "click" (fn this.select @model)}} class="{{this.selected}}" ...attributes> {{#if @model.rootRow}}
<td>{{@model.ulb}}</td> <tr {{on "click" (fn this.select @model)}} ...attributes>
<td>{{@model.greek}}</td> <td rowspan="{{@rowspan}}">{{@model.ulb}}</td>
<td>{{@model.morph}}</td> <td class="{{this.selected}}">{{@model.greek}}</td>
</tr> <td class="{{this.selected}}">{{@model.morph}}</td>
</tr>
{{else}}
<tr {{on "click" (fn this.select @model)}} class="{{this.selected}}" ...attributes>
{{#if this.isNotPhrasePartial}}
<td>{{@model.ulb}}</td>
{{/if}}
<td>{{@model.greek}}</td>
<td>{{@model.morph}}</td>
</tr>
{{/if}}

View File

@ -21,4 +21,13 @@ export default class WordsWordRowComponent extends Component {
return ""; return "";
} }
} }
get
isNotPhrasePartial() {
if (this.args.isPartial == true) {
return false;
} else {
return true;
}
}
} }

View File

@ -9,7 +9,8 @@ table.word-details td {
cursor: pointer; cursor: pointer;
} }
table.word-details tr.selected { table.word-details tr.selected,
table.word-details td.selected {
background-color: lightblue; background-color: lightblue;
} }