1

I have created a angular-meteor page for settings. In that settings page menus are listed and when a menu is selected then it is displayed in home page. When unchecked it is removed from dashboard. The code is

in client side js `angular.module('demo').directive('generalSettings', function() {

return {
    restrict: 'E',
    templateUrl: 'client/lms/general-settings.html',
    controllerAs: 'generalSettingsCtrl',
    controller: function($scope, $reactive, $stateParams, $mdDialog, $state, $mdToast, ToastService, $timeout, $q, $log, errorValidatorUtil, CurrentPage) {
        $reactive(this).attach($scope)
        let self = this;
        let user = Meteor.user();
        let userId = Meteor.userId();
        let customerId = [userId]
        self.subscribe('getCustomerDetails', () => [customerId], {
            onReady: function() {
                self.helpers({
                    currentUser: () => {
                        return Meteor.users.findOne({
                            _id: Meteor.userId()
                        });

                    }
                })
            }
        });
        // console.log(Meteor.users.findOne({
        //     _id: Meteor.userId()
        // }))

        self.data = {};
        self.data.cb1 = true;
        self.isChecked = true;
        CurrentPage.setTitle('Settings');
        self.subscribe('generalSettingsDetails', () => [], {
            onReady: function() {
                self.helpers({ /// helpers to make it reactive
                    generalSettings: () => {
                        let settings = GeneralSettings.find({}).fetch()
                            //var subSettings = []
                        for (key in settings) {

                            delete settings[key].$$hashKey

                        }
                        console.log(settings)
                        return {
                            'generalSetting': settings
                        };
                    }
                })
            }


        });
        self.getClicked = (dynamicSetting, settingId, detail) => {
            self.dataArry = {};
            self.dataChk = {};

            self.generalSetting = {};


            console.log(self.generalSettings.generalSetting)


            Meteor.call("updateStatus", detail, function(error, result) {
                if (error) {

                    ToastService.getToastbox($mdToast, 'Something went error!Unable to add details', 'error-toast');
                } else {
                    self.generalSetting = {};

                    ToastService.getToastbox($mdToast, 'Details added successfully !', 'success-toast');

                }
            });


        }

    }
}

}) and the server js is like`Meteor.methods({ updateStatus: function(settings, status) { let _ids = [] console.log(settings) if (settings.$$hashKey) delete settings.$$hashKey

    GeneralSettings.update({
        _id: settings._id

    }, {
        $set: {
            "status": settings.status
        }
    }, {
        "multi": true
    })
}

})

and the html is like

<div layout="column" layout-wrap layout-padding layout-fill class="littleWhiteFrame" ng-cloak>
<div>
    <div layout="row" class="requestDetailElems">
        <h4 class="md-subhead" layout-marginSettings> Settings</h4>
        <span flex></span>
    </div>
</div>
<md-divider></md-divider>
<div layout="row">
<fieldset class="standard">
    <div layout-gt-sm="row"  ng-repeat="detail in generalSettingsCtrl.generalSettings.generalSetting">
        <md-checkbox aria-label="Checkbox 1"  ng-model="detail.status" ng-change="generalSettingsCtrl.getClicked(generalSettingsCtrl.detail[$index],currentUser._id,detail)">

               <p> {{detail.name}} {{ detail.data.cb1 }}</p>
        </md-checkbox>
    </div>
    </fieldset>
</div>

i have a mongo collection for settings with fields like id,name,description,tag,status.

when the menu is selected status will get changed to true.

Now I want to make some changes in this code,I want to make different menu for different users. So in the user collection I have to push the selected menu. For eg:user1,user2 if user1 selects home,about us from settings then in his dashboard home and aboutus should be viewed. if user2 selects home and testimonial then when he login home and testimonial should be viewed not home and aboutus

2 Answers 2

0

You just push the settings collection to user collection.And you can fetch the data according to user id.

Meteor.users.update(

{ _id: userId }, { "$push": { "settings": settingDetails } } )

Sign up to request clarification or add additional context in comments.

Comments

0

You can create separate menu bar and show them using ng-if .

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.