mattbrailsford / umbraco-photon

Image map plugin for Umbraco 7
Other
8 stars 6 forks source link

List available doc types #2

Open bjarnef opened 8 years ago

bjarnef commented 8 years ago

For the meta data doc type, can we list the available doc types - just like in Nested Content where it has a dropdown with the available doc types?

image

bjarnef commented 8 years ago

It can use the same approach as the current version of Nested Content, where it use its own API controller .. or use getAll method in contentTypeResource - however I think it was added in Umbraco 7.4.0 https://github.com/umbraco/Umbraco-CMS/blob/75c2b07ad3a093b5b65b6ebd45697687c062f62a/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js#L149

See also this issue created in Nested Content https://github.com/leekelleher/umbraco-nested-content/issues/78

bjarnef commented 8 years ago

It could use something like the following using contentTypeResource or should we just stick to its own ApiController?

angular.module('umbraco').controller("Our.Umbraco.Photon.Controllers.DocTypePickerController",
    function ($scope, contentTypeResource, photonResources) {
        var umbVersion = Umbraco.Sys.ServerVariables.application.version;

        //if umbVersion >= 7.4.0 use contentTypeResource.getAll()
        //else use photonResources.getContentTypes()

        //example from Nested Content
        //ncResources.getContentTypes().then(function (docTypes) {
            //$scope.model.docTypes = docTypes;
        //});
    });

and it should probably have a method then for comparing the version number.

bjarnef commented 8 years ago

An example from Umbraco Forms:

var umbracoVersion = Umbraco.Sys.ServerVariables.application.version;

        $scope.openMediaPicker = function() {

            var compareOptions = {
                zeroExtend: true
            };

            var versionCompare = utilityService.compareVersions(umbracoVersion, "7.4", compareOptions);

            if(versionCompare === 0 || versionCompare === 1) {

                $scope.mediaPickerOverlay = {
                    view: "mediapicker",
                    show: true,
                    submit: function(model) {

                        var selectedImage = model.selectedImages[0];
                        populateFile(selectedImage);

                        $scope.mediaPickerOverlay.show = false;
                        $scope.mediaPickerOverlay = null;
                    }
                };

            } else {

                dialogService.mediaPicker({ callback: populateFile });

            }

        };