-
Notifications
You must be signed in to change notification settings - Fork 34
Country prediction during series creation #547
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (C) 2009-2017 Slava Semushin <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package ru.mystamps.web.controller; | ||
|
||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
import ru.mystamps.web.Url; | ||
import ru.mystamps.web.controller.converter.annotation.CurrentUser; | ||
import ru.mystamps.web.service.CountryService; | ||
|
||
@Controller | ||
@RequiredArgsConstructor | ||
public class SuggestionController { | ||
|
||
private final CountryService countryService; | ||
|
||
/** | ||
* @author John Shkarin | ||
*/ | ||
@ResponseBody | ||
@GetMapping(Url.SUGGEST_SERIES_COUNTRY) | ||
public String suggestCountryForUser(@CurrentUser Integer currentUserId) { | ||
return countryService.suggestCountryForUser(currentUserId); | ||
} | ||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// IMPORTANT: | ||
// You have to update Url.RESOURCES_VERSION each time whenever you're modified this file! | ||
// | ||
function initPage() { | ||
function initPage(suggestCountryUrl) { | ||
$('#country').selectize(); | ||
|
||
$('.js-catalog-numbers').on('blur', function() { | ||
|
@@ -21,4 +21,23 @@ function initPage() { | |
$('.js-with-tooltip').tooltip({ | ||
'placement': 'right' | ||
}); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Посмотри в шапке этого файла и не забудь поправить константу в классе |
||
if (suggestCountryUrl == null) { | ||
return; | ||
} | ||
|
||
$.get(suggestCountryUrl, function (slug) { | ||
if (slug == null) | ||
return; | ||
|
||
var country = $("#guess_country"); | ||
country.show(); | ||
country.click(function() { | ||
$(this).hide(); | ||
|
||
var select_country = $("#country").selectize(); | ||
var selectize = select_country[0].selectize; | ||
selectize.setValue(slug); | ||
}); | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Почему этот файл еще тут? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Все еще актуально. |
||
-- Auto-generated by Maven, based on values from src/main/resources/test/spring/test-data.properties | ||
-- | ||
|
||
INSERT INTO series(id, quantity, perforated, country_id, created_at, created_by, updated_at, updated_by, category_id) VALUES | ||
(2, 1, 1, 2, NOW() + 1, 1, NOW(), 4, 1); | ||
|
||
INSERT INTO series(id, quantity, perforated, country_id, created_at, created_by, updated_at, updated_by, category_id) VALUES | ||
(3, 1, 1, 2, NOW() + 2, 1, NOW(), 4, 1); | ||
|
||
INSERT INTO series(id, quantity, perforated, country_id, created_at, created_by, updated_at, updated_by, category_id) VALUES | ||
(4, 1, 1, 2, NOW() + 3, 1, NOW(), 4, 1); | ||
|
||
INSERT INTO series(id, quantity, perforated, country_id, created_at, created_by, updated_at, updated_by, category_id) VALUES | ||
(5, 1, 1, 2, NOW() + 4, 1, NOW(), 4, 1); | ||
|
||
INSERT INTO series(id, quantity, perforated, country_id, created_at, created_by, updated_at, updated_by, category_id) VALUES | ||
(6, 1, 1, 4, NOW() + 5, 1, NOW(), 4, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Обрати внимание на это сообщение.