-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #388 from datacite/field_size_id
size, format and version fields in DOI form
- Loading branch information
Showing
26 changed files
with
912 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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,17 @@ | ||
import Component from '@ember/component'; | ||
|
||
export default Component.extend({ | ||
|
||
actions: { | ||
updateFormat(value) { | ||
this.set('fragment', value); | ||
}, | ||
selectFormat() { | ||
console.log(this.fragment); | ||
this.model.get('formats').replace(this.index, 1, [ this.fragment ]); | ||
}, | ||
deleteFormat() { | ||
this.model.get('formats').removeAt(this.index); | ||
}, | ||
}, | ||
}); |
This file contains 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,21 @@ | ||
import Component from '@ember/component'; | ||
|
||
export default Component.extend({ | ||
validationClass: null, | ||
|
||
didReceiveAttrs() { | ||
this._super(...arguments); | ||
|
||
if (!this.model.get('formats')) { | ||
this.model.set('formats', []); | ||
} | ||
if (this.model.get('formats').length == 0) { | ||
this.model.get('formats').pushObject(); | ||
} | ||
}, | ||
actions: { | ||
addFormat() { | ||
this.model.get('formats').pushObject(); | ||
}, | ||
}, | ||
}); |
This file contains 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,18 @@ | ||
import Component from '@ember/component'; | ||
// import { set } from '@ember/object'; | ||
|
||
export default Component.extend({ | ||
|
||
actions: { | ||
updateSize(value) { | ||
this.set('fragment', value); | ||
}, | ||
selectSize() { | ||
console.log(this.fragment); | ||
this.model.get('sizes').replace(this.index, 1, [ this.fragment ]); | ||
}, | ||
deleteSize() { | ||
this.model.get('sizes').removeAt(this.index); | ||
}, | ||
}, | ||
}); |
This file contains 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,21 @@ | ||
import Component from '@ember/component'; | ||
|
||
export default Component.extend({ | ||
validationClass: null, | ||
|
||
didReceiveAttrs() { | ||
this._super(...arguments); | ||
|
||
if (!this.model.get('sizes')) { | ||
this.model.set('sizes', []); | ||
} | ||
if (this.model.get('sizes').length == 0) { | ||
this.model.get('sizes').pushObject(); | ||
} | ||
}, | ||
actions: { | ||
addSize() { | ||
this.model.get('sizes').pushObject(); | ||
}, | ||
}, | ||
}); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,14 @@ | ||
|
||
<label for="format" class="subtitle">Format (optional)</label> | ||
{{#if (gt index 0)}} | ||
<div class="input-group"> | ||
<input type="text" class="form-control format-field" value={{fragment}} oninput={{action "updateFormat" value="target.value"}} onblur={{action "selectFormat" }} data-test-format/> | ||
<span class="input-group-addon"> | ||
<BsButton @outline={{true}} @onClick={{action "deleteFormat" index}}>{{fa-icon "trash" pull="left" style="margin:0;"}}</BsButton> | ||
</span> | ||
</div> | ||
{{else}} | ||
<input type="text" class="form-control format-field" value={{fragment}} oninput={{action "updateFormat" value="target.value"}} onblur={{action "selectFormat" }} data-test-format/> | ||
{{/if}} | ||
<div class="help-block help-block-fragment format-field">Technical format of the resource. </div> | ||
<hr /> |
This file contains 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,12 @@ | ||
<div class="form-group {{validationClass}}"> | ||
<label class="control-label col-md-3">Format(s) (optional)</label> | ||
<div class="col-md-9"> | ||
{{#each model.formats as |format index|}} | ||
<DoiFormat @model={{model}} @fragment={{format}} @form={{form}} @index={{index}} /> | ||
{{/each}} | ||
|
||
{{#if (or (not model.formats) (lte model.formats.length 5))}} | ||
<BsButton @class="btn-sm" @id="add-format" @outline={{true}} @onClick={{action "addFormat"}}>{{fa-icon "plus"}} Add {{if (gt model.formats.length 0) "another "}}format</BsButton> | ||
{{/if}} | ||
</div> | ||
</div> |
This file contains 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,13 @@ | ||
<label for="size" class="subtitle">Size (optional)</label> | ||
{{#if (gt index 0)}} | ||
<div class="input-group"> | ||
<input type="text" class="form-control size-field" value={{fragment}} oninput={{action "updateSize" value="target.value"}} onblur={{action "selectSize" }} data-test-size/> | ||
<span class="input-group-addon"> | ||
<BsButton @outline={{true}} @onClick={{action "deleteSize" index}}>{{fa-icon "trash" pull="left" style="margin:0;"}}</BsButton> | ||
</span> | ||
</div> | ||
{{else}} | ||
<input type="text" class="form-control size-field" value={{fragment}} oninput={{action "updateSize" value="target.value"}} onblur={{action "selectSize" }} data-test-size/> | ||
{{/if}} | ||
<div class="help-block help-block-fragment size-field">Size (e.g. bytes, pages, inches, etc.) or duration (extent), e.g. hours, minutes, days, etc., of a resource. </div> | ||
<hr /> |
This file contains 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,12 @@ | ||
<div class="form-group {{validationClass}}"> | ||
<label class="control-label col-md-3">Size(s) (optional)</label> | ||
<div class="col-md-9"> | ||
{{#each model.sizes as |size index|}} | ||
<DoiSize @model={{model}} @fragment={{size}} @form={{form}} @index={{index}} /> | ||
{{/each}} | ||
|
||
{{#if (or (not model.sizes) (lte model.sizes.length 5))}} | ||
<BsButton @class="btn-sm" @id="add-size" @outline={{true}} @onClick={{action "addSize"}}>{{fa-icon "plus"}} Add {{if (gt model.sizes.length 0) "another "}}size</BsButton> | ||
{{/if}} | ||
</div> | ||
</div> |
This file contains 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
This file contains 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
565 changes: 565 additions & 0 deletions
565
...i_1416311633/visiting-the-Form-and-adding-format-version-and-size_455109108/recording.har
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,18 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { render } from '@ember/test-helpers'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
// import { selectChoose } from 'ember-power-select/test-support'; | ||
import { setupFactoryGuy, make } from 'ember-data-factory-guy'; | ||
|
||
module('Integration | Component | doi format', function(hooks) { | ||
setupRenderingTest(hooks); | ||
setupFactoryGuy(hooks); | ||
|
||
test('it renders', async function(assert) { | ||
this.set('model', make('doi')); | ||
await render(hbs`{{doi-format model=model fragment=fragment index=0}}`); | ||
|
||
assert.dom('*').hasText('Format (optional) Technical format of the resource.'); | ||
}); | ||
}); |
Oops, something went wrong.