Skip to content

Combine Default profile and Editing profile options into Active profile #1983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions ext/js/pages/settings/profile-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ export class ProfileController {
/** @type {HTMLSelectElement} */
this._profileActiveSelect = querySelectorNotNull(document, '#profile-active-select');
/** @type {HTMLSelectElement} */
this._profileTargetSelect = querySelectorNotNull(document, '#profile-target-select');
/** @type {HTMLSelectElement} */
this._profileCopySourceSelect = querySelectorNotNull(document, '#profile-copy-source-select');
/** @type {HTMLElement} */
this._removeProfileNameElement = querySelectorNotNull(document, '#profile-remove-name');
Expand Down Expand Up @@ -91,7 +89,6 @@ export class ProfileController {
this._profileEntriesSupported = (this._profileEntryListContainer !== null);

if (this._profileActiveSelect !== null) { this._profileActiveSelect.addEventListener('change', this._onProfileActiveChange.bind(this), false); }
if (this._profileTargetSelect !== null) { this._profileTargetSelect.addEventListener('change', this._onProfileTargetChange.bind(this), false); }
if (this._profileAddButton !== null) { this._profileAddButton.addEventListener('click', this._onAdd.bind(this), false); }
if (this._profileRemoveConfirmButton !== null) { this._profileRemoveConfirmButton.addEventListener('click', this._onDeleteConfirm.bind(this), false); }
if (this._profileCopyConfirmButton !== null) { this._profileCopyConfirmButton.addEventListener('click', this._onCopyConfirm.bind(this), false); }
Expand Down Expand Up @@ -394,19 +391,16 @@ export class ProfileController {
this._profiles = profiles;
this._profileCurrent = profileCurrent;

const settingsProfileIndex = this._settingsController.profileIndex;

// Udpate UI
this._updateProfileSelectOptions();

/** @type {HTMLSelectElement} */ (this._profileActiveSelect).value = `${profileCurrent}`;
/** @type {HTMLSelectElement} */ (this._profileTargetSelect).value = `${settingsProfileIndex}`;

// Update profile conditions
this._profileConditionsUI.cleanup();
const conditionsProfile = this._getProfile(this._profileConditionsIndex !== null ? this._profileConditionsIndex : settingsProfileIndex);
const conditionsProfile = this._getProfile(this._profileConditionsIndex !== null ? this._profileConditionsIndex : profileCurrent);
if (conditionsProfile !== null) {
void this._profileConditionsUI.prepare(settingsProfileIndex);
void this._profileConditionsUI.prepare(profileCurrent);
}

// Udpate profile entries
Expand All @@ -429,15 +423,6 @@ export class ProfileController {
const value = this._tryGetValidProfileIndex(element.value);
if (value === null) { return; }
void this.setDefaultProfile(value);
}

/**
* @param {Event} e
*/
_onProfileTargetChange(e) {
const element = /** @type {HTMLSelectElement} */ (e.currentTarget);
const value = this._tryGetValidProfileIndex(element.value);
if (value === null) { return; }
this._settingsController.profileIndex = value;
}

Expand Down Expand Up @@ -536,7 +521,6 @@ export class ProfileController {
_getAllProfileSelects() {
return [
/** @type {HTMLSelectElement} */ (this._profileActiveSelect),
/** @type {HTMLSelectElement} */ (this._profileTargetSelect),
/** @type {HTMLSelectElement} */ (this._profileCopySourceSelect),
];
}
Expand Down
13 changes: 2 additions & 11 deletions ext/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,13 @@ <h1>Yomitan Settings</h1>
<div class="settings-group">
<div class="settings-item"><div class="settings-item-inner settings-item-inner-wrappable">
<div class="settings-item-left">
<div class="settings-item-label">Default profile</div>
<div class="settings-item-description">Switch the default profile that is used for scanning.</div>
<div class="settings-item-label">Active profile</div>
<div class="settings-item-description">Switch the active profile that is used for scanning.</div>
</div>
<div class="settings-item-right">
<select id="profile-active-select"></select>
</div>
</div></div>
<div class="settings-item"><div class="settings-item-inner settings-item-inner-wrappable">
<div class="settings-item-left">
<div class="settings-item-label">Editing profile</div>
<div class="settings-item-description">Change which profile is being modified on this page.</div>
</div>
<div class="settings-item-right">
<select id="profile-target-select"></select>
</div>
</div></div>
<div class="settings-item settings-item-button" data-modal-action="show,profiles"><div class="settings-item-inner">
<div class="settings-item-left">
<div class="settings-item-label">Configure profiles&hellip;</div>
Expand Down
Loading