-
Notifications
You must be signed in to change notification settings - Fork 34
Address to #1345 #1359
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
Closed
splin-shady
wants to merge
1
commit into
php-coder:master
from
splin-shady:gh1345_react-add-country-form
Closed
Address to #1345 #1359
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
class AddCountryForm extends React.Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
nameInEnglish: "", | ||
nameInRussian: "" | ||
}; | ||
this.handleSubmit = this.handleSubmit.bind(this); | ||
this.handleChange = this.handleChange.bind(this); | ||
} | ||
|
||
handleChange(event) { | ||
event.preventDefault(); | ||
this.setState({ | ||
[event.target.name]: event.target.value | ||
}); | ||
} | ||
|
||
handleSubmit(event) { | ||
event.preventDefault(); | ||
|
||
this.setState({}); | ||
|
||
axios.post( | ||
"categories",{},{} | ||
).then(response => { | ||
|
||
}).catch(error => { | ||
|
||
}); | ||
|
||
} | ||
|
||
render() { | ||
return ( | ||
<form id="add-country-form" className="form-horizontal" onSubmit={this.handleSubmit} | ||
/* method="post" action="info.html" th:action="@{${ADD_COUNTRY_PAGE}}" th:object="${addCountryForm}" */> | ||
|
||
<div className="form-group" /* th:classappend="${#fields.hasErrors('name') ? 'has-error' : ''}" */> | ||
<label htmlFor="name" className="control-label col-sm-4"> | ||
<span /* th:remove="tag" th:text="#{t_name_in_english}" */> | ||
Name (in English) | ||
</span> | ||
<span className="required_field">*</span> | ||
</label> | ||
<div className="col-sm-5"> | ||
<input id="name" | ||
type="text" | ||
className="form-control" | ||
value={this.state.nameInEnglish} | ||
name="nameInEnglish" | ||
required="required" | ||
onChange={this.handleChange} /* th:field="*{name}" */ /> | ||
{/* | ||
<span id="name.errors" class="help-block" th:if="${#fields.hasErrors('name')}" th:each="error : ${#fields.errors('name')}" th:text="${error}"></span> | ||
*/} | ||
</div> | ||
</div> | ||
|
||
<div className="form-group" /* th:classappend="${#fields.hasErrors('nameRu') ? 'has-error' : ''}" */> | ||
<label htmlFor="nameRu" className="control-label col-sm-4" /* th:text="#{t_name_in_russian}" */> | ||
Name (in Russian) | ||
</label> | ||
<div className="col-sm-5"> | ||
<input id="nameRu" | ||
type="text" | ||
className="form-control" | ||
value={this.state.nameInRussian} | ||
name="nameInRussian" | ||
onChange={this.handleChange} /* th:field="*{nameRu}" */ /> | ||
{/* | ||
<span id="nameRu.errors" class="help-block" th:if="${#fields.hasErrors('nameRu')}" th:each="error : ${#fields.errors('nameRu')}" th:text="${error}"></span> | ||
*/} | ||
</div> | ||
</div> | ||
|
||
<div className="form-group"> | ||
<div className="col-sm-offset-4 col-sm-5"> | ||
<input type="submit" | ||
className="btn btn-primary" | ||
value="Add" /* th:value="#{t_add}" */ /> | ||
</div> | ||
</div> | ||
|
||
</form> | ||
) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,43 +73,8 @@ <h3 th:text="${#strings.capitalize(add_country)}"> | |
</small> | ||
</div> | ||
|
||
<form id="add-country-form" method="post" class="form-horizontal" action="info.html" | ||
th:action="@{${ADD_COUNTRY_PAGE}}" th:object="${addCountryForm}"> | ||
|
||
<div class="form-group" th:classappend="${#fields.hasErrors('name') ? 'has-error' : ''}"> | ||
<label for="name" class="control-label col-sm-4"> | ||
<span th:remove="tag" th:text="#{t_name_in_english}"> | ||
Name (in English) | ||
</span> | ||
<span class="required_field">*</span> | ||
</label> | ||
<div class="col-sm-5"> | ||
<input id="name" type="text" class="form-control" required="required" th:field="*{name}" /> | ||
<!--/*/ | ||
<span id="name.errors" class="help-block" th:if="${#fields.hasErrors('name')}" th:each="error : ${#fields.errors('name')}" th:text="${error}"></span> | ||
/*/--> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group" th:classappend="${#fields.hasErrors('nameRu') ? 'has-error' : ''}"> | ||
<label for="nameRu" class="control-label col-sm-4" th:text="#{t_name_in_russian}"> | ||
Name (in Russian) | ||
</label> | ||
<div class="col-sm-5"> | ||
<input id="nameRu" type="text" class="form-control" th:field="*{nameRu}" /> | ||
<!--/*/ | ||
<span id="nameRu.errors" class="help-block" th:if="${#fields.hasErrors('nameRu')}" th:each="error : ${#fields.errors('nameRu')}" th:text="${error}"></span> | ||
/*/--> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<div class="col-sm-offset-4 col-sm-5"> | ||
<input type="submit" class="btn btn-primary" value="Add" th:value="#{t_add}" /> | ||
</div> | ||
</div> | ||
|
||
</form> | ||
<div id="add-country-form-react"></div> | ||
|
||
</div> | ||
</div> | ||
<div class="row"> | ||
|
@@ -123,5 +88,14 @@ <h3 th:text="${#strings.capitalize(add_country)}"> | |
<!-- Placed at the end of the document so the pages load faster --> | ||
<script src="http://yandex.st/jquery/1.9.1/jquery.min.js" th:src="${JQUERY_JS}"></script> | ||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" th:src="${BOOTSTRAP_JS}"></script> | ||
|
||
<script src="https://unpkg.com/[email protected]/umd/react.development.js" th:src="${REACT_JS}"></script> | ||
<script src="https://unpkg.com/[email protected]/umd/react-dom.development.js" th:src="${REACT_DOM_JS}"></script> | ||
<script src="https://unpkg.com/[email protected]/dist/axios.js" th:src="${AXIOS_JS}"></script> | ||
|
||
<script src="../../../../../../target/classes/js/components/AddCountryForm.js"></script> | ||
<script th:inline="javascript"> | ||
ReactDOM.render(React.createElement(AddCountryForm), document.getElementById('add-country-form-react')); | ||
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. Let's render into |
||
</script> | ||
</body> | ||
</html> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This PR shouldn't remove the existing form. React component just should be rendered to the same element.