feat: create new links directly from contact pages

Contact detail: + New Link button redirects to link form with contact context.
Contact create/edit form: inline new link rows (label/url/role) created on submit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 14:44:54 +00:00
parent e334e0e9db
commit fbdf986fa8
5 changed files with 68 additions and 1 deletions

View File

@@ -52,6 +52,7 @@
</datalist>
</div>
<button type="submit" class="btn btn-primary btn-sm">Add</button>
<a href="/links/create?contact_id={{ item.id }}" class="btn btn-ghost btn-sm">+ New Link</a>
</form>
{% for l in links %}
<div class="list-row">

View File

@@ -34,6 +34,7 @@
{% endif %}
</div>
<button type="button" class="btn btn-ghost btn-sm" id="add-link-btn">+ Add Link</button>
<button type="button" class="btn btn-ghost btn-sm" id="add-new-link-btn">+ Create New Link</button>
<datalist id="link-roles">
<option value="website">
<option value="portfolio">
@@ -65,6 +66,15 @@
'<button type="button" class="btn btn-ghost btn-xs" style="color:var(--red);" onclick="this.closest(\'.contact-link-row\').remove()">&times;</button>';
document.getElementById('contact-links-list').appendChild(row);
});
document.getElementById('add-new-link-btn').addEventListener('click', function() {
var row = document.createElement('div');
row.className = 'flex gap-2 items-center mb-2 contact-link-row';
row.innerHTML = '<input type="text" name="new_link_labels" class="form-input" placeholder="Label *" required style="flex:1;">' +
'<input type="url" name="new_link_urls" class="form-input" placeholder="URL *" required style="flex:2;">' +
'<input type="text" name="new_link_roles" class="form-input" list="link-roles" placeholder="Role..." style="flex:1;">' +
'<button type="button" class="btn btn-ghost btn-xs" style="color:var(--red);" onclick="this.closest(\'.contact-link-row\').remove()">&times;</button>';
document.getElementById('contact-links-list').appendChild(row);
});
})();
</script>
{% endblock %}

View File

@@ -15,7 +15,8 @@
<div class="form-group full-width"><label class="form-label">Description</label><textarea name="description" class="form-textarea" rows="3">{{ item.description if item and item.description else '' }}</textarea></div>
{% if prefill_task_id is defined and prefill_task_id %}<input type="hidden" name="task_id" value="{{ prefill_task_id }}">{% endif %}
{% if prefill_meeting_id is defined and prefill_meeting_id %}<input type="hidden" name="meeting_id" value="{{ prefill_meeting_id }}">{% endif %}
<div class="form-actions"><button type="submit" class="btn btn-primary">{{ 'Save' if item else 'Create' }}</button><a href="{{ '/projects/' ~ prefill_project_id ~ '?tab=links' if prefill_project_id is defined and prefill_project_id else ('/tasks/' ~ prefill_task_id ~ '?tab=links' if prefill_task_id is defined and prefill_task_id else '/links') }}" class="btn btn-secondary">Cancel</a></div>
{% if prefill_contact_id is defined and prefill_contact_id %}<input type="hidden" name="contact_id" value="{{ prefill_contact_id }}">{% endif %}
<div class="form-actions"><button type="submit" class="btn btn-primary">{{ 'Save' if item else 'Create' }}</button><a href="{{ '/contacts/' ~ prefill_contact_id if prefill_contact_id is defined and prefill_contact_id else ('/projects/' ~ prefill_project_id ~ '?tab=links' if prefill_project_id is defined and prefill_project_id else ('/tasks/' ~ prefill_task_id ~ '?tab=links' if prefill_task_id is defined and prefill_task_id else '/links')) }}" class="btn btn-secondary">Cancel</a></div>
</div>
</form></div>
{% endblock %}