mirror of
https://gitlab.com/Deukhoofd/BattleSim.git
synced 2025-10-27 18:00:03 +00:00
Added Text Editing for teams
This commit is contained in:
@@ -133,6 +133,7 @@ class @TeambuilderView extends Backbone.View
|
||||
exportTeam: (e) =>
|
||||
$team = $(e.currentTarget).closest('.select-team')
|
||||
id = $team.data('id')
|
||||
name = $team.data('name')
|
||||
if not @getTeam(id).hasNonNullPokemon()
|
||||
alert("You cannot export empty teams. Please add some pokemon first.")
|
||||
return false
|
||||
@@ -140,9 +141,28 @@ class @TeambuilderView extends Backbone.View
|
||||
teamJSON = @getTeam(id).toNonNullJSON()
|
||||
teamString = PokeBattle.exportTeam(teamJSON.pokemon)
|
||||
|
||||
$modal = PokeBattle.modal('modals/export_team')
|
||||
$modal.find('.exported-team').val(teamString)
|
||||
$modal.find('textarea, input').first().focus().select()
|
||||
$modal = PokeBattle.modal 'modals/export_team', ($modal) =>
|
||||
$modal.find('.exported-team').val(teamString)
|
||||
$modal.on 'click', '.import-team-submit', (e) =>
|
||||
teamString = $modal.find('.exported-team').val()
|
||||
pokemonJSON = PokeBattle.parseTeam(teamString)
|
||||
errors = @validateImportedTeam(pokemonJSON)
|
||||
if errors.length > 0
|
||||
listErrors = errors.map((e) -> "<li>#{e}</li>").join('')
|
||||
$errors = $modal.find('.form-errors')
|
||||
$errors.html("<ul>#{listErrors}</ul>").removeClass('hidden')
|
||||
else
|
||||
jint = 0
|
||||
for jPkmn in pokemonJSON
|
||||
@getTeam(id).replace(jint, jPkmn)
|
||||
jint = jint+1
|
||||
@getTeam(id).save()
|
||||
$modal.find('.imported-team').val("")
|
||||
$modal.modal('hide')
|
||||
return false
|
||||
$modal.find('.exported-team').first().focus()
|
||||
|
||||
|
||||
return false
|
||||
|
||||
addNewPokemonEvent: =>
|
||||
|
||||
@@ -7,4 +7,5 @@
|
||||
.control-group
|
||||
textarea.exported-team.textarea_modal
|
||||
.modal-footer
|
||||
button.button.import-team-submit(data-dismiss="modal", aria-hidden="true", style="margin-right: 5px") Import
|
||||
button.button(data-dismiss="modal", aria-hidden="true") Close
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
.team-meta
|
||||
span.fake_link.export-team
|
||||
span.icon-upload
|
||||
| Export
|
||||
| Text Editor
|
||||
| |
|
||||
span.fake_link.clone-team
|
||||
span.icon-copy
|
||||
|
||||
Reference in New Issue
Block a user