Skip to content

Commit

Permalink
Merge branch 'i182_relationship_form'
Browse files Browse the repository at this point in the history
  • Loading branch information
pollardld committed Nov 26, 2024
2 parents 7c44fa4 + 6ecea96 commit 4fcae05
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
8 changes: 5 additions & 3 deletions TEKDB/TEKDB/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class Meta:
}
fields = '__all__'


class ResourcesMediaEventsForm(forms.ModelForm):
class Meta:
model = ResourcesMediaEvents
Expand All @@ -194,6 +195,7 @@ class Meta:
'relationshipdescription': CKEditorWidget
}
fields = '__all__'


class PlaceAltIndigenousNameForm(forms.ModelForm):
class Meta:
Expand Down Expand Up @@ -556,7 +558,7 @@ class MediaAdmin(RecordAdminProxy, RecordModelAdmin):
'enteredbyname','enteredbydate')
fieldsets = (
(None, {
'fields': (('medianame','mediatype','limitedaccess'),'mediafile','medialink','mediadescription',)
'fields': (('medianame','mediatype','limitedaccess'),'mediafile','medialink','mediadescription','mediabulkupload',)
}),
('Review', {
'fields': (
Expand Down Expand Up @@ -808,7 +810,7 @@ class PlacesMediaEventsAdmin(RecordAdminProxy):
})
)
form = PlacesMediaEventsForm

class PlaceAltIndigenousNameAdmin(VersionAdmin):
fieldsets = (
('', {
Expand Down Expand Up @@ -861,7 +863,7 @@ class ResourceActivityCitationEventsAdmin(RecordAdminProxy):
})
)
form = ResourceActivityCitationEventsForm

class ResourceActivityMediaEventsAdmin(RecordAdminProxy):
list_display = ('resourceactivityid','mediaid','enteredbyname','enteredbydate','modifiedbyname','modifiedbydate')
fieldsets = (
Expand Down
28 changes: 17 additions & 11 deletions TEKDB/TEKDB/static/TEKDB/js/record_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,27 @@ loadFormModal = function(module, model, id, action, base_model, base_id, fk_fiel
}
html +='/?_popup=1"></iframe>';
$('#form-modal-body').html(html);
$('#popup-iframe-form').load(function(){
$('#popup-iframe-form').on('load', function() {
if (action != 'delete') {
if (action == 'add') {
$('#popup-iframe-form').contents().find('#id_' + fk_field_id).parent().replaceWith('<input name="' + fk_field_id + '" id="id_' + fk_field_id + '" value="' + base_id + '"></input>');
}
// If below only shown for 'add', users could move relationships to new records
// For now I'm not sure this feature is intuitive or desired.
$('#popup-iframe-form').contents().find('#id_' + fk_field_id).hide();
$('#popup-iframe-form').contents().find('.field-box.field-' + fk_field_id).hide();
all_buttons = $('#popup-iframe-form').contents().find('.submit-row input');
if (action == 'add') {
$('#popup-iframe-form').contents().find('#id_' + fk_field_id).parent().replaceWith('<input name="' + fk_field_id + '" id="id_' + fk_field_id + '" value="' + base_id + '"></input>');
}
$('#popup-iframe-form').contents().find('#id_' + fk_field_id).hide();
$('#popup-iframe-form').contents().find('.field-box.field-' + fk_field_id).hide();
$('#popup-iframe-form').contents().find('label[for="id_' + fk_field_id + '"]').hide();
all_buttons = $('#popup-iframe-form').contents().find('.submit-row input');
} else {
all_buttons = $('#popup-iframe-form').contents().find('form div').children(':not([type="hidden"])');
all_buttons = $('#popup-iframe-form').contents().find('form div').children(':not([type="hidden"])');
}
all_buttons.attr('data-toggle', 'modal');
all_buttons.attr('data-target', '#inlineFormModal');
all_buttons.on('click', function(){iframeButtonClicked(base_model, base_id);});
all_buttons.on('click', function() { iframeButtonClicked(base_model, base_id); });
});
}

window.addEventListener('message', function(event) {
// Check for the specific action you expect
if (event.data.action === 'closeAndRefresh') {
window.location.reload(); // Refresh the parent page
}
});

0 comments on commit 4fcae05

Please sign in to comment.