/// class PD.Manage.Modules.Resources.LocationMonitor
// using PD.Web.UI.Controls.Control

PD.Manage.Modules.Resources.LocationMonitor =
PD.Web.UI.Controls.Control.extend({

    onInit: function (e) {
        this.subscriptions.add("location/change", _.bind(this.change, this));
    },

    change: function (e) {

        PD.ajax({
            url: PD.Path.resolve("~/Manage/Resources/GetFolderPath/"),
            data: {
                folderId: e.folderId || null
            },
            success: function (args) {

                PD.context
                    .get_default()
                    .get_events()
                    .publish("location/changed", {
                        folderId: e.folderId,
                        source: e.source,
                        path: _.map(args, "id"),
                        data: _.map(args, function (item) {
                            return { id: item.id, name: item.name };
                        })
                    });

            }
        });

    }

});