Skip to content

Commit

Permalink
Fix some UI consistency issues
Browse files Browse the repository at this point in the history
- Disable prev/next, placeholder after buttons on deselect
- Check for typeahead value change before marking dirty bit on unselectedAdaptation()
  • Loading branch information
eb1 committed Aug 15, 2024
1 parent 4d139e5 commit 7a989c0
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions www/js/views/AdaptViews.js
Original file line number Diff line number Diff line change
Expand Up @@ -1968,8 +1968,8 @@ define(function (require) {
$("#mnuRetranslation .topcoat-icon").addClass("topcoat-icon--retranslation-new");
}
$("#phBefore").prop('disabled', false);
$("#mnuPHBefore").prop('disabled', false);
$("#phAfter").prop('disabled', false);
$("#mnuPHBefore").prop('disabled', false);
$("#mnuPHAfter").prop('disabled', false);
event.stopPropagation();
} else if (editorMode === editorModeEnum.FREE_TRANSLATING) {
Expand Down Expand Up @@ -2986,18 +2986,25 @@ define(function (require) {
// find the model object associated with this edit field
strID = $(event.currentTarget.parentElement).attr('id');
if (strID === undefined) {
console.log("value: " + value);
// make sure the typeahead gets cleaned out and the value saved
isDirty = true;
// no strID (typeahead) - pull the model from the parent element (which has an ID)
console.log("Typeahead value: " + value);
isSelectingKB = false;
// this might be the tt-input div if we are in a typeahead (multiple KB) input -
// if so, go up one more level to find the pile
strID = $(event.currentTarget.parentElement.parentElement).attr('id');
strID = strID.substr(strID.indexOf("-") + 1); // remove "pile-"
model = this.collection.findWhere({spid: strID});
// destroy the typeahead control in the edit field
$(event.currentTarget).typeahead('destroy');
// did the value change?
if (model.get('target') !== value) {
isDirty = true;
}
} else {
// "normal" pile with a valid strID -- get the model
strID = strID.substr(strID.indexOf("-") + 1); // remove "pile-"
model = this.collection.findWhere({spid: strID});
}
strID = strID.substr(strID.indexOf("-") + 1); // remove "pile-"
model = this.collection.findWhere({spid: strID});
// re-add autocaps if necessary
if (trimmedValue.length > 0) {
trimmedValue = this.stripPunctuation(this.autoAddCaps(model, trimmedValue), false);
Expand Down Expand Up @@ -3031,6 +3038,7 @@ define(function (require) {
// add any punctuation back to the target field
$(event.currentTarget).html(this.copyPunctuation(model, trimmedValue));
// update the model with the new target text
console.log("unselectedAdaptation - saving model source: " + model.get('source'));
model.save({target: this.copyPunctuation(model, trimmedValue)});
// if the target differs from the source, make it display in green
if (model.get('source') === model.get('target')) {
Expand Down Expand Up @@ -3072,9 +3080,16 @@ define(function (require) {
if (selectedStart !== null) {
// there was an old selection -- remove the ui-selected class
$("div").removeClass("ui-selecting ui-selected");
// $("#Placeholder").prop('disabled', true);
// $("#Retranslation").prop('disabled', true);
// $("#Phrase").prop('disabled', true);
// $("#phBefore").prop('disabled', true);
// $("#phAfter").prop('disabled', true);
// $("#Retranslation").prop('disabled', true);
// $("#Phrase").prop('disabled', true);
// $("#mnuPHBefore").prop('disabled', true);
// $("#mnuPHAfter").prop('disabled', true);
// $("#mnuRetranslation").prop('disabled', true);
// $("#mnuPhrase").prop('disabled', true);
// $("#PrevSP").prop('disabled', true);
// $("#NextSP").prop('disabled', true);
}
// remove any old selection ranges
if (window.getSelection) {
Expand Down Expand Up @@ -3462,6 +3477,7 @@ define(function (require) {
// start adapting at this location
$("div").removeClass("ui-selecting ui-selected");
$("#phBefore").prop('disabled', true);
$("#phAfter").prop('disabled', true);
$("#Retranslation").prop('disabled', true);
$("#Phrase").prop('disabled', true);
$("#mnuPHBefore").prop('disabled', true);
Expand Down Expand Up @@ -4588,11 +4604,14 @@ define(function (require) {
if (selectedStart !== null) {
$("div").removeClass("ui-selecting ui-selected ui-longSelecting");
$("#phBefore").prop('disabled', true);
$("#phAfter").prop('disabled', true);
$("#Retranslation").prop('disabled', true);
$("#Phrase").prop('disabled', true);
$("#mnuPHBefore").prop('disabled', true);
$("#mnuRetranslation").prop('disabled', true);
$("#mnuPhrase").prop('disabled', true);
$("#PrevSP").prop('disabled', true);
$("#NextSP").prop('disabled', true);
}
// disable the "more translations" menu
if (!$("#mnuTranslations").hasClass("menu-disabled")) {
Expand Down

0 comments on commit 7a989c0

Please sign in to comment.