Skip to content

Commit

Permalink
- Added tag help text
Browse files Browse the repository at this point in the history
- Update tag buttons / tag help text based on availability of tags
- Use cursor pointer for buttons in translation wizard
- Update list of available translations each time a translation is
added/removed
- Added empty default database
  • Loading branch information
tobias-klein committed Feb 3, 2019
1 parent a19b55b commit 77b24d6
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 11 deletions.
19 changes: 16 additions & 3 deletions app/bible_browser/bible_browser_controller.js
Expand Up @@ -508,6 +508,10 @@ function BibleBrowserController() {
};

this.handle_book_menu_click = function(event) {
if ($('.book-select-button').hasClass('ui-state-disabled')) {
return;
}

if (bible_browser_controller.book_menu_is_opened) {
bible_browser_controller.handle_body_click();
} else {
Expand All @@ -531,6 +535,10 @@ function BibleBrowserController() {
};

this.handle_tag_menu_click = function(event) {
if ($('.tag-select-button').hasClass('ui-state-disabled')) {
return;
}

if (bible_browser_controller.tag_menu_is_opened) {
bible_browser_controller.handle_body_click();
} else {
Expand Down Expand Up @@ -581,15 +589,20 @@ function BibleBrowserController() {
}
};

this.bind_events_after_bible_text_loaded = function() {
this.bind_events_after_bible_text_loaded = async function() {
$('.cr-info').filter(":not('.tag-events-configured')").bind('click', bible_browser_controller.handle_cross_reference_click).addClass('tag-events-configured');
$('.tag-box, .cr-box').filter(":not('.tag-events-configured')").bind('click', tags_controller.clear_verse_selection).addClass('tag-events-configured');
$('.tag').filter(":not('.tag-events-configured')").bind('click', bible_browser_controller.handle_tag_reference_click).addClass('tag-events-configured');

if (bible_browser_controller.text_is_book) {
var tagsCount = await models.Tag.getTagCount();
var book_tag_statistics_button = $('#show-book-tag-statistics-button');
book_tag_statistics_button.removeClass('ui-state-disabled');
book_tag_statistics_button.removeClass('events-configured');

if (tagsCount > 0) {
book_tag_statistics_button.removeClass('ui-state-disabled');
book_tag_statistics_button.removeClass('events-configured');
}

book_tag_statistics_button.bind('click', function() {
bible_browser_controller.open_book_tag_statistics();
});
Expand Down
7 changes: 5 additions & 2 deletions app/bible_browser/translation_wizard.js
Expand Up @@ -264,9 +264,10 @@ class TranslationWizard {
return this._translationInstallStatus != 'IN_PROGRESS';
}

addTranslationWizardFinished(event, currentIndex) {
async addTranslationWizardFinished(event, currentIndex) {
$('#translation-settings-wizard').dialog('close');

this._installedTranslations = await models.BibleTranslation.getTranslations();
$('#bible-select').removeAttr('disabled');
initTranslationsMenu();
}
Expand Down Expand Up @@ -323,6 +324,7 @@ class TranslationWizard {
$("select#bible-select").empty();
initTranslationsMenu();
updateNavMenu();
tags_controller.updateTagUiBasedOnTagAvailability();
});
}

Expand All @@ -338,8 +340,9 @@ class TranslationWizard {
return this._translationRemovalStatus != 'IN_PROGRESS';
}

removeTranslationWizardFinished(event, currentIndex) {
async removeTranslationWizardFinished(event, currentIndex) {
$('#translation-settings-wizard').dialog('close');
this._installedTranslations = await models.BibleTranslation.getTranslations();
initTranslationsMenu();
}

Expand Down
2 changes: 1 addition & 1 deletion app/tags/tags_communication_controller.js
Expand Up @@ -81,7 +81,7 @@ function TagsCommunicationController()
});
};

this.destroy_tag = function(id) {
this.destroy_tag = async function(id) {
models.VerseTag.destroy({
where: {
tagId: id
Expand Down
39 changes: 35 additions & 4 deletions app/tags/tags_controller.js
Expand Up @@ -248,6 +248,10 @@ function TagsController() {
};

this.handle_new_tag_button_click = function(button, type) {
if ($(button).hasClass('ui-state-disabled')) {
return;
}

$('#new-' + type + '-tag-title-input').val('');
$('#new-' + type + '-tag-dialog').dialog('open');
$('#new-' + type + '-tag-title-input').focus();
Expand Down Expand Up @@ -294,8 +298,9 @@ function TagsController() {
$('#delete-meta-tag-confirmation-dialog').dialog('close');
};

this.delete_tag_after_confirmation = function() {
tags_controller.communication_controller.destroy_tag(tags_controller.tag_to_be_deleted);
this.delete_tag_after_confirmation = async function() {
await tags_controller.communication_controller.destroy_tag(tags_controller.tag_to_be_deleted);
await tags_controller.updateTagUiBasedOnTagAvailability();
$('#delete-tag-confirmation-dialog').dialog('close');
};

Expand Down Expand Up @@ -656,7 +661,7 @@ function TagsController() {
return $('#tags-search-input')[0].empty();
};

this.render_tags = function(tag_list) {
this.render_tags = async function(tag_list) {
var book_content_header = $($('#tags-content').find('.ui-accordion-header')[1]);
var global_tags_box = $('#tags-content-global');
var book_tags_box = $('#tags-content-book');
Expand All @@ -681,6 +686,8 @@ function TagsController() {
var current_filter = $('#tags-search-input').val();
var book_tag_statistics = new Array();

await tags_controller.updateTagUiBasedOnTagAvailability();

for (var i = 0; i < tag_list.length; i++) {
var current_tag = tag_list[i];
var current_tag_title = current_tag.title;
Expand Down Expand Up @@ -1528,7 +1535,7 @@ function TagsController() {
new_reference_link.append(tags_search_input);
};

this.init_ui = function() {
this.init_ui = async function() {
$('#tags-content').accordion({
autoHeight: false,
animated: false,
Expand Down Expand Up @@ -1562,6 +1569,30 @@ function TagsController() {
$('#tags-search-input').bind('keydown', function(e) {
e.stopPropagation();
});

await tags_controller.updateTagUiBasedOnTagAvailability();
};

this.updateTagUiBasedOnTagAvailability = async function() {
var translations = await models.BibleTranslation.getTranslations();
var translationCount = translations.length;
var tagsCount = await models.Tag.getTagCount();

if (tagsCount == 0) {
$('.tag-select-button').addClass('ui-state-disabled');
$('#show-book-tag-statistics-button').addClass('ui-state-disabled');

if (translationCount > 0) {
$('#tags-content-global').html(gettext_strings.help_text_no_tags_book_opened);
} else {
$('#new-standard-tag-button').addClass('ui-state-disabled');
$('#tags-content-global').html(gettext_strings.help_text_no_tags);
}
} else {
$('.tag-select-button').removeClass('ui-state-disabled');
$('#new-standard-tag-button').removeClass('ui-state-disabled');
$('#show-book-tag-statistics-button').removeClass('ui-state-disabled');
}
};

this.init = function() {
Expand Down
4 changes: 4 additions & 0 deletions css/main.css
Expand Up @@ -619,6 +619,10 @@ h2 {
float: left;
}

.fg-button {
cursor: pointer;
}

.display-options-button {
width: 7.5em;
}
Expand Down
Binary file added ezra.sqlite
Binary file not shown.
4 changes: 3 additions & 1 deletion index.html
Expand Up @@ -68,7 +68,9 @@
book_select_label : 'Select book',
tagged_verses_for : 'Verses tagged with ',
help_text_no_translations : 'To start using Ezra Project, first install at least one bible translation by clicking on "Configure translations" and then "Add bible translation".',
help_text_translation_available : 'To start using Ezra Project, select a book or a tag from the menu above.'
help_text_translation_available : 'To start using Ezra Project, select a book or a tag from the menu above.',
help_text_no_tags : 'To start working with tags, first select a bible book to study.',
help_text_no_tags_book_opened : 'To start working with tags, create your first tag by clicking on the button "New&nbsp;tag" above. After that you can browse the bible text, click or drag-select verses and then assign the tag you just created.'
};

var bible_books = [
Expand Down
2 changes: 2 additions & 0 deletions init.js
Expand Up @@ -421,8 +421,10 @@ async function initTranslationsMenu()

if (result.count == 0) {
$('#bible-select').attr('disabled','disabled');
$('.book-select-button').addClass('ui-state-disabled');
$('#verse-list').find('.help-text').text(gettext_strings.help_text_no_translations);
} else if (bible_browser_controller.current_book == null && bible_browser_controller.current_tag_id_list == "") {
$('.book-select-button').removeClass('ui-state-disabled');
$('#verse-list').find('.help-text').text(gettext_strings.help_text_translation_available);
}

Expand Down
6 changes: 6 additions & 0 deletions models/tag.js
Expand Up @@ -41,5 +41,11 @@ module.exports = (sequelize, DataTypes) => {
return sequelize.query(query, { model: models.Tag });
};

Tag.getTagCount = async function() {
var query = "SELECT id FROM Tags t";
var records = await sequelize.query(query, { model: models.Tag });
return records.length;
};

return Tag;
};

0 comments on commit 77b24d6

Please sign in to comment.