Add interface for copying tags from other photos.
This commit is contained in:
parent
bc5a9f2116
commit
89205ac24a
3 changed files with 43 additions and 0 deletions
|
@ -110,6 +110,18 @@ def post_photo_add_tag(photo_id):
|
|||
)
|
||||
return response
|
||||
|
||||
@site.route('/photo/<photo_id>/copy_tags', methods=['POST'])
|
||||
@decorators.required_fields(['other_photo'], forbid_whitespace=True)
|
||||
def post_photo_copy_tags(photo_id):
|
||||
'''
|
||||
Copy the tags from another photo.
|
||||
'''
|
||||
photo = common.P_photo(photo_id, response_type='json')
|
||||
other = common.P_photo(request.form['other_photo'], response_type='json')
|
||||
photo.copy_tags(other)
|
||||
common.P.commit('photo copy tags')
|
||||
return jsonify.make_json_response([tag.jsonify(minimal=True) for tag in photo.get_tags()])
|
||||
|
||||
@site.route('/photo/<photo_id>/remove_tag', methods=['POST'])
|
||||
@decorators.required_fields(['tagname'], forbid_whitespace=True)
|
||||
def post_photo_remove_tag(photo_id):
|
||||
|
|
|
@ -239,6 +239,15 @@ function batch_unset_searchhidden(photo_ids, callback)
|
|||
common.post(url, data, callback);
|
||||
}
|
||||
|
||||
api.photos.copy_tags =
|
||||
function copy_tags(photo_id, other_photo, callback)
|
||||
{
|
||||
const url = `/photo/${photo_id}/copy_tags`;
|
||||
const data = new FormData();
|
||||
data.append("other_photo", other_photo);
|
||||
common.post(url, data, callback)
|
||||
}
|
||||
|
||||
api.photos.delete =
|
||||
function _delete(photo_id, delete_file, callback)
|
||||
{
|
||||
|
|
|
@ -257,6 +257,18 @@
|
|||
{% if photo.simple_mimetype == "video" %}
|
||||
<button id="generate_thumbnail_button" class="green_button button_with_spinner" onclick="return generate_thumbnail_for_video_form();">Capture thumbnail</button>
|
||||
{% endif %}
|
||||
|
||||
<button
|
||||
class="green_button button_with_confirm"
|
||||
data-holder-id="copy_other_photo_tags_holder"
|
||||
data-is-input="1"
|
||||
data-prompt="Other photo ID"
|
||||
data-cancel-class="gray_button"
|
||||
data-onclick="return copy_other_photo_tags_form(event);"
|
||||
>
|
||||
Copy tags from other photo
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="red_button button_with_confirm"
|
||||
data-onclick="return delete_photo_form();"
|
||||
|
@ -331,6 +343,16 @@ function add_photo_tag_callback(response)
|
|||
sort_tag_cards();
|
||||
}
|
||||
|
||||
function copy_other_photo_tags_form(event)
|
||||
{
|
||||
const other_photo = event.target.input_source.value;
|
||||
if (! other_photo.trim())
|
||||
{
|
||||
return;
|
||||
}
|
||||
api.photos.copy_tags(PHOTO_ID, other_photo, common.refresh_or_alert);
|
||||
}
|
||||
|
||||
function remove_photo_tag_form(photo_id, tagname)
|
||||
{
|
||||
api.photos.remove_tag(photo_id, tagname, remove_photo_tag_callback);
|
||||
|
|
Loading…
Reference in a new issue