Skip to content

Commit

Permalink
Merge pull request #232 from nextcloud/create-by-enter
Browse files Browse the repository at this point in the history
Create or edit calendars by pressing Enter key
  • Loading branch information
raimund-schluessler authored Jan 26, 2019
2 parents 4c21b81 + 6876538 commit 8e98e3f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/components/TheList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}"
class="edit"
type="text"
@keyup="checkName($event, calendar.id)"
@keyup="checkName($event, calendar, save)"
>
<input :title="t('tasks', 'Cancel')"
type="cancel"
Expand Down Expand Up @@ -149,7 +149,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
:placeholder="t('tasks', 'New List')"
class="edit"
type="text"
@keyup="checkName($event, '')"
@keyup="checkName($event, null, create)"
>
<input :title="t('tasks', 'Cancel')"
type="cancel"
Expand Down Expand Up @@ -330,16 +330,20 @@ export default {
this.changeCalendar({ calendar: calendar, newName: this.newCalendarName, newColor: this.selectedColor })
this.editing = false
},
checkName: function(event, id) {
var check = this.isNameAllowed(this.newCalendarName, id)
checkName: function(event, calendar, callback) {
const calendarId = calendar ? calendar.id : ''
const check = this.isNameAllowed(this.newCalendarName, calendarId)
this.tooltipMessage = check.msg
if (!check.allowed) {
this.tooltipTarget = 'list_' + id
this.tooltipTarget = 'list_' + calendarId
this.nameError = true
} else {
this.tooltipTarget = ''
this.nameError = false
}
if (event.keyCode === 13) {
callback(calendar)
}
if (event.keyCode === 27) {
event.preventDefault()
this.tooltipTarget = ''
Expand Down

0 comments on commit 8e98e3f

Please sign in to comment.