Skip to content

Commit

Permalink
Translate textareas and add placeholders back
Browse files Browse the repository at this point in the history
  • Loading branch information
lcpriest committed Nov 13, 2018
1 parent cd36416 commit c5a621b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
9 changes: 0 additions & 9 deletions addon/components/form-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,6 @@ const FormFieldComponent = Component.extend(TranslatedInput, {
return get(this, 'modelName') || guidFor(get(this, 'object'));
},

getModelName() {
let formName = get(this, 'form');
let modelName = get(this, 'object.modelName');
let constructorName = get(this, 'object.constructor.modelName');
let changesetConstructorName = get(this, 'object._content.constructor.modelName');

return formName || modelName || constructorName || changesetConstructorName;
},

value: computed('rawValue', function() {
let serializeValue = getWithDefault(this, 'serializeValue', (value) => value);
return serializeValue(get(this, 'rawValue'));
Expand Down
3 changes: 2 additions & 1 deletion addon/components/form-fields/text-field.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import Ember from 'ember';
import layout from '../../templates/components/form-fields/text-field';
import TranslatedInput from '../../mixins/translated-input';

const {
Component,
set
} = Ember;

const TextFieldComponent = Component.extend({
const TextFieldComponent = Component.extend(TranslatedInput, {
tagName: '',
layout,

Expand Down
3 changes: 2 additions & 1 deletion addon/components/form-fields/textarea-field.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import Ember from 'ember';
import layout from '../../templates/components/form-fields/textarea-field';
import TranslatedInput from '../../mixins/translated-input';

const {
Component,
set
} = Ember;

const TextareaFieldComponent = Component.extend({
const TextareaFieldComponent = Component.extend(TranslatedInput, {
tagName: '',
layout,

Expand Down
14 changes: 14 additions & 0 deletions addon/mixins/translated-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ const {

export default Mixin.create({
intl: service(),
config: service('ember-form-for/config'),

modelName: computed('form', 'object.{modelName,constructor.modelName,_content.constructor.modelName}', function() {
return this.getModelName();
}),

getModelName() {
let formName = get(this, 'form');
let modelName = get(this, 'object.modelName');
let constructorName = get(this, 'object.constructor.modelName');
let changesetConstructorName = get(this, 'object._content.constructor.modelName');

return formName || modelName || constructorName || changesetConstructorName;
},

labelText: computed('propertyName', 'label', function() {
let intl = get(this, 'intl');
Expand Down
2 changes: 1 addition & 1 deletion addon/templates/components/form-fields/hidden-field.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
minlength=minlength
multiple=multiple
pattern=pattern
placeholder=placeholderText
placeholder=placeholder
readonly=readonly
required=required
size=size
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-form-for-intl",
"version": "1.0.4",
"version": "1.0.6",
"description": "Build \"Data Down Actions Up\" forms, with good default markup and built-in accessibility support",
"keywords": [
"ember-addon"
Expand Down

0 comments on commit c5a621b

Please sign in to comment.