Skip to content
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

Do not allow disabling both types of breaks #190

Merged
merged 1 commit into from
Jan 20, 2018
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed
- style for long names of schemes
- app not starting when both break types are disabled

## [0.14.0] - 2018-01-07
### Fixed
Expand Down
3 changes: 2 additions & 1 deletion app/locales/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"minutes)": "минути)",
"microbreaksEnabled": "активиране на микропочивките",
"breaksEnabled": "активиране на почивките",
"resetToDefaults": "нулиране към начални настройки"
"resetToDefaults": "нулиране към начални настройки",
"cantDisableBoth": "Can't disable both break types."
},
"settings2": {
"settings": "Настройки",
Expand Down
4 changes: 2 additions & 2 deletions app/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
"minutes)": "minut)",
"microbreaksEnabled": "povolit mikropřestávky",
"breaksEnabled": "povolit přestávky",
"resetToDefaults": "obnovit původní nastavení"
"resetToDefaults": "obnovit původní nastavení",
"cantDisableBoth": "Can't disable both break types."
},
"settings2": {
"settings": "Nastavení",
Expand Down Expand Up @@ -109,4 +110,3 @@
"newVersionAvailable": "Je dostupná nová verze!"
}
}

3 changes: 2 additions & 1 deletion app/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"minutes)": "Minuten)",
"microbreaksEnabled": "Mikropausen aktiv",
"breaksEnabled": "Pausen aktiv",
"resetToDefaults": "Auf Standardeinstellung zurücksetzen"
"resetToDefaults": "Auf Standardeinstellung zurücksetzen",
"cantDisableBoth": "Can't disable both break types."
},
"settings2": {
"settings": "Einstellungen",
Expand Down
3 changes: 2 additions & 1 deletion app/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"minutes)": "minutes)",
"microbreaksEnabled": "microbreaks enabled",
"breaksEnabled": "breaks enabled",
"resetToDefaults": "reset to defaults"
"resetToDefaults": "reset to defaults",
"cantDisableBoth": "Can't disable both break types."
},
"settings2": {
"settings": "Settings",
Expand Down
3 changes: 2 additions & 1 deletion app/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"minutes)": "minutes)",
"microbreaksEnabled": "activer les petites pauses",
"breaksEnabled": "activer les grandes pauses",
"resetToDefaults": "revenir aux paramètres d'origine"
"resetToDefaults": "revenir aux paramètres d'origine",
"cantDisableBoth": "Veuillez activer l'une des deux pauses proposées"
},
"settings2": {
"settings": "Settings",
Expand Down
3 changes: 2 additions & 1 deletion app/locales/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
"graphiteCrystal": "cristal <br/>de grafite",
"coffeeKisses": "beijos <br/> de café",
"morningSwim": "banho <br/> matinal",
"resetToDefaults": "restaurar a configuração padrão"
"resetToDefaults": "restaurar a configuração padrão",
"cantDisableBoth": "Can't disable both break types."
},
"settings3": {
"settings": "Configurações",
Expand Down
3 changes: 2 additions & 1 deletion app/locales/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
"minutes)": "minút)",
"microbreaksEnabled": "povoliť mikroprestávky",
"breaksEnabled": "povoliť prestávky",
"resetToDefaults": "obnoviť pôvodné nastavenia"
"resetToDefaults": "obnoviť pôvodné nastavenia",
"cantDisableBoth": "Nie je možné nepovoliť obe prestávky."
},
"settings2": {
"settings": "Nastavenia",
Expand Down
3 changes: 2 additions & 1 deletion app/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"minutes)": "分钟)",
"microbreaksEnabled": "启用短时间休息",
"breaksEnabled": "启用长时间休息",
"resetToDefaults": "重置为默认值"
"resetToDefaults": "重置为默认值",
"cantDisableBoth": "Can't disable both break types."
},
"settings2": {
"settings": "设置",
Expand Down
2 changes: 1 addition & 1 deletion app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ <h2 data-i18next="settings.breaks"></h2>
</p>
<div>
<div class="enabled">
<input type="checkbox" value="microbreak" class="enable">
<input type="checkbox" value="microbreak" class="enable enabletype">
<span data-i18next="settings.microbreaksEnabled">
</div>
<div class="enabled">
<input type="checkbox" value="break" class="enable">
<input type="checkbox" value="break" class="enable enabletype">
<span data-i18next="settings.breaksEnabled">
</div>
<div class="next">
Expand Down
31 changes: 29 additions & 2 deletions app/settings.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const {ipcRenderer} = require('electron')
const {ipcRenderer, remote} = require('electron')
const HtmlTranslate = require('./utils/htmlTranslate')
const i18next = remote.require('i18next')

document.addEventListener('DOMContentLoaded', event => {
new HtmlTranslate(document).translate()
Expand Down Expand Up @@ -78,7 +79,7 @@ breakDurationMinus.addEventListener('click', function (e) {

ipcRenderer.on('renderSettings', (event, data) => {
let enableElements = document.getElementsByClassName('enable')
for (var i = 0; i < enableElements.length; i++) {
for (let i = 0; i < enableElements.length; i++) {
let element = enableElements[i]
element.checked = data[element.value]
if (!eventsAttached) {
Expand All @@ -88,6 +89,20 @@ ipcRenderer.on('renderSettings', (event, data) => {
}
}

let enableBreakTypeElements = document.getElementsByClassName('enabletype')
for (let i = 0; i < enableBreakTypeElements.length; i++) {
let element = enableBreakTypeElements[i]
if (!eventsAttached) {
element.addEventListener('click', function (e) {
if (enabletypeCheckedCount() === 0) {
element.checked = 'true'
ipcRenderer.send('save-setting', element.value, element.checked)
alert(i18next.t('settings.cantDisableBoth'))
}
})
}
}

microbreakInterval.innerHTML = data['microbreakInterval'] / 1000 / 60
microbreakDuration.innerHTML = data['microbreakDuration'] / 1000
breakInterval.innerHTML = data['breakInterval']
Expand All @@ -99,6 +114,18 @@ ipcRenderer.on('renderSettings', (event, data) => {
eventsAttached = true
})

let enabletypeCheckedCount = function () {
let enabled = 0
let enableBreakTypeElements = document.getElementsByClassName('enabletype')
for (let i = 0; i < enableBreakTypeElements.length; i++) {
let element = enableBreakTypeElements[i]
if (element.checked) {
enabled += 1
}
}
return enabled
}

document.getElementById('defaults').addEventListener('click', function (e) {
ipcRenderer.send('set-default-settings', [
'break',
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@
"afterEach",
"Audio",
"fetch",
"Notification"
"Notification",
"alert"
]
},
"dependencies": {
Expand Down