commit 9a4eea6c133543f977fde29c6a914da95f2d30d8
parent 19ab6cc9f1e936c6d333850d5bd297f7ea0f976c
Author: Timo A. Hummel <felicitus@felicitus.org>
Date: Mon, 27 Jul 2015 21:00:22 +0200
Added storage location image service, fixed storage location image functionality
Diffstat:
5 files changed, 70 insertions(+), 7 deletions(-)
diff --git a/app/config/config.yml b/app/config/config.yml
@@ -539,6 +539,36 @@ services:
arguments:
- { groups: [ "default" ] }
+ resource.storage_location_image.item_operation.custom_get:
+ class: "Dunglas\ApiBundle\Api\Operation\Operation"
+ public: false
+ factory: [ "@api.operation_factory", "createItemOperation" ]
+ arguments:
+ - "@resource.storage_location_image" # Resource
+ - [ "GET" ] # Methods
+ - "/storage_location_images/{id}/getImage" # Path
+ - "PartKeeprStorageLocationBundle:StorageLocationImage:getImage" # Controller
+ - "StorageLocationGetImage" # Route name
+ - # Context (will be present in Hydra documentation)
+ "@type": "hydra:Operation"
+ "hydra:title": "A custom operation"
+ "returns": "xmls:string"
+
+ resource.storage_location_image:
+ parent: "api.resource"
+ arguments: [ "PartKeepr\StorageLocationBundle\Entity\StorageLocationImage" ]
+ tags: [ { name: "api.resource" } ]
+ calls:
+ - method: "initItemOperations"
+ arguments: [ [ "@resource.storage_location_image.item_operation.custom_get" ] ]
+ - method: "initFilters"
+ arguments: [ [ "@doctrine_reflection_service.search_filter" ] ]
+ - method: "initNormalizationContext"
+ arguments: [ { groups: [ "default" ] } ]
+ - method: "initDenormalizationContext"
+ arguments:
+ - { groups: [ "default" ] }
+
# ######################## Temporary Images ######################################
resource.tempimage.collection_operation.custom_post:
class: "Dunglas\ApiBundle\Api\Operation\Operation"
diff --git a/app/config/partkeepr.yml b/app/config/partkeepr.yml
@@ -6,4 +6,5 @@ partkeepr:
tempfile: %kernel.root_dir%/../data/files/Temporary/
footprintattachment: %kernel.root_dir%/../data/files/FootprintAttachment/
footprint: %kernel.root_dir%/../data/images/footprint/
+ storagelocation: %kernel.root_dir%/../data/images/storagelocation/
mimetype_icons: %kernel.root_dir%/../src/PartKeepr/MimetypeIconsBundle/Resources/public/images/mimes/
\ No newline at end of file
diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintEditor.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintEditor.js
@@ -49,7 +49,6 @@ Ext.define('PartKeepr.FootprintEditor', {
items: {
xtype: 'remoteimagefield',
itemId: 'image',
- imageType: 'footprint',
maxHeight: 256,
maxWidth: 256,
listeners: {
diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/StorageLocation/StorageLocationEditor.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/StorageLocation/StorageLocationEditor.js
@@ -4,6 +4,7 @@ Ext.define('PartKeepr.StorageLocationEditor', {
saveText: i18n("Save Storage Location"),
layout: 'column',
+ defaultListenerScope: true,
initComponent: function () {
var config = {};
@@ -75,12 +76,17 @@ Ext.define('PartKeepr.StorageLocationEditor', {
}, {
width: 370,
height: 250,
- xtype: 'remoteimagefield',
- name: 'image_id',
- imageType: 'storagelocation',
- imageWidth: 256,
- imageHeight: 256,
- labelWidth: 110,
+ xtype: 'fieldcontainer',
+ items: {
+ xtype: 'remoteimagefield',
+ itemId: 'image',
+ maxHeight: 256,
+ maxWidth: 256,
+ listeners: {
+ 'fileUploaded': "onFileUploaded"
+ }
+ },
+ labelWidth: 75,
fieldLabel: i18n("Image")
}
];
@@ -88,6 +94,17 @@ Ext.define('PartKeepr.StorageLocationEditor', {
this.on("startEdit", this.onStartEdit, this);
this.callParent();
},
+ onFileUploaded: function (data) {
+ var uploadedFile = Ext.create("PartKeepr.UploadedFileBundle.Entity.TempUploadedFile", data);
+
+ if (this.record.getImage() === null) {
+ this.record.setImage(data);
+ } else {
+ this.record.getImage().set("replacement", uploadedFile.getId());
+ }
+
+ this.down('#image').setValue(uploadedFile);
+ },
onStartEdit: function () {
var filter = Ext.create("Ext.util.Filter", {
property: "storageLocation",
@@ -97,6 +114,7 @@ Ext.define('PartKeepr.StorageLocationEditor', {
this.store.addFilter(filter);
this.store.load();
+ this.down('#image').setValue(this.record.getImage());
}
});
\ No newline at end of file
diff --git a/src/PartKeepr/StorageLocationBundle/Controller/StorageLocationImageController.php b/src/PartKeepr/StorageLocationBundle/Controller/StorageLocationImageController.php
@@ -0,0 +1,15 @@
+<?php
+namespace PartKeepr\StorageLocationBundle\Controller;
+
+use PartKeepr\ImageBundle\Controller\ImageController;
+
+class StorageLocationImageController extends ImageController
+{
+ /**
+ * @inheritdoc
+ */
+ protected function getEntityClass()
+ {
+ return "PartKeepr\\StorageLocationBundle\\Entity\\StorageLocationImage";
+ }
+}