Fixed source and tag editing

This commit is contained in:
Dan Elbert 2018-07-13 16:01:56 -05:00
parent 7071a7203b
commit bc681481ab
3 changed files with 26 additions and 3 deletions

View File

@ -23,7 +23,10 @@
<div class="level-item has-text-centered">
<div>
<p class="heading">Source</p>
<p class="title is-6">{{recipe.source}}</p>
<p class="title is-6">
<a v-if="isSourceUrl" :href="sourceUrl">{{sourceText}}</a>
<span v-else>{{sourceText}}</span>
</p>
</div>
</div>
</div>
@ -182,6 +185,26 @@
}
return t + a;
},
sourceUrl() {
try {
return new URL(this.recipe.source);
} catch(err) {
return null;
}
},
isSourceUrl() {
return this.sourceUrl !== null;
},
sourceText() {
if (this.isSourceUrl) {
return this.sourceUrl.host;
} else {
return this.source;
}
}
},

View File

@ -155,7 +155,7 @@ class Api {
total_time: recipe.total_time,
active_time: recipe.active_time,
step_text: recipe.step_text,
tag_names: recipe.tag_names,
tag_names: recipe.tags,
recipe_ingredients_attributes: recipe.ingredients.map(i => {
if (i._destroy) {
return {

View File

@ -1,6 +1,6 @@
json.extract! recipe, :id, :name, :rating, :yields, :total_time, :active_time, :created_at, :updated_at, :step_text, :converted_scale, :converted_system, :converted_unit
json.extract! recipe, :id, :name, :rating, :yields, :total_time, :active_time, :source, :created_at, :updated_at, :step_text, :converted_scale, :converted_system, :converted_unit
json.rendered_steps MarkdownProcessor.render(recipe.step_text)