mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 07:05:41 +00:00 
			
		
		
		
	Part image delete (#3963)
* Add button to remove an associated image from a part - Also fixes some issues with onclick event propagation * Similar feature for company image
This commit is contained in:
		@@ -502,8 +502,34 @@
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    $("#part-image-upload").click(function() {
 | 
			
		||||
    $('#part-image-delete').click(function(event) {
 | 
			
		||||
        event.stopPropagation();
 | 
			
		||||
        showQuestionDialog(
 | 
			
		||||
            '{% trans "Remove Image" %}',
 | 
			
		||||
            '{% trans "Remove associated image from this part" %}',
 | 
			
		||||
            {
 | 
			
		||||
                accept_text: '{% trans "Remove" %}',
 | 
			
		||||
                submitClass: 'danger',
 | 
			
		||||
                accept: function() {
 | 
			
		||||
                    inventreePut(
 | 
			
		||||
                        '{% url "api-part-detail" part.pk %}',
 | 
			
		||||
                        {
 | 
			
		||||
                            'image': null,
 | 
			
		||||
                        },
 | 
			
		||||
                        {
 | 
			
		||||
                            method: 'PATCH',
 | 
			
		||||
                            success: function(data) {
 | 
			
		||||
                                location.reload();
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    );
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        );
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    $("#part-image-upload").click(function(event) {
 | 
			
		||||
        event.stopPropagation();
 | 
			
		||||
        constructForm(
 | 
			
		||||
            '{% url "api-part-detail" part.pk %}',
 | 
			
		||||
            {
 | 
			
		||||
@@ -576,12 +602,12 @@
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $("#part-image-select").click(function() {
 | 
			
		||||
        launchModalForm("{% url 'part-image-select' part.id %}",
 | 
			
		||||
                        {
 | 
			
		||||
                            reload: true,
 | 
			
		||||
                            after_render: onSelectImage
 | 
			
		||||
                        });
 | 
			
		||||
    $("#part-image-select").click(function(event) {
 | 
			
		||||
        event.stopPropagation();
 | 
			
		||||
        launchModalForm("{% url 'part-image-select' part.id %}", {
 | 
			
		||||
            reload: true,
 | 
			
		||||
            after_render: onSelectImage
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    $("#part-edit").click(function() {
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,9 @@
 | 
			
		||||
            {% if allow_download %}
 | 
			
		||||
            <button type='button' class='btn btn-outline-secondary' title="{% trans 'Download image from URL' %}" id='part-image-url'><span class='fas fa-cloud-download-alt'></span></button>
 | 
			
		||||
            {% endif %}
 | 
			
		||||
            {% if part.image %}
 | 
			
		||||
            <button type='button' class='btn btn-outline-secondary' title='{% trans "Delete image" %}' id='part-image-delete'><span class='fas fa-trash-alt icon-red'></span></button>
 | 
			
		||||
            {% endif %}
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    {% endif %}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user