Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- firebase.auth().onAuthStateChanged(function (user) {
- if (user) {
- $scope.signed_out = false
- $scope.displayName = user.displayName
- }
- else {
- $state.go( 'login' );
- $scope.signed_out = true
- }
- });
- $scope.sign_out = function () {
- firebase.auth().signOut().then(function () {
- console.log('Signed Out');
- }, function (error) {
- console.error('Sign Out Error', error);
- });
- }
- //////////////////////////////////
- // Accordion Controller Underneath
- //////////////////////////////////
- $scope.page_data = {}
- $scope.page_data.groups = {}
- $scope.page_data.comment_models = {}
- var group_ids = {}
- Firebase.check_user().then(function (data) {
- user_details = data
- $scope.get_groups(data)
- console.log("user_details", user_details)
- })
- $scope.get_groups = function (input) {
- // trigger Firebase function.
- Firebase.get_groups(input.groups)
- .then(function (groups) {
- console.info("input", input)
- console.info("groups", groups)
- $scope.groups = groups
- })
- }
- //togglestar
- $scope.toggleStar = function (group) {
- group.star = !group.star;
- }
- //delete function
- $scope.onItemDelete = function (group) {
- var input = {
- uid: $scope.groups[group].created_by,
- group_id: $scope.groups[group].id,
- }
- Firebase.remove_group(input)
- delete $scope.groups[group]
- }
- //ReOrder function
- $scope.moveItem = function (group, fromIndex, toIndex) {
- $scope.groups.splice(fromIndex, 1);
- $scope.groups.splice(toIndex, 0, group);
- };
- /*
- * if given group is the selected group, deselect it
- * else, select the given group
- */
- $scope.toggleGroup = function (group) {
- if ($scope.isGroupShown(group)) {
- $scope.shownGroup = null;
- } else {
- $scope.shownGroup = group;
- }
- };
- $scope.isGroupShown = function (group) {
- return $scope.shownGroup === group;
- };
- });
- <div class="headerDash">
- <h4 class="padding center headerText">Welcome {{ displayName }}</h4>
- </div>
- <ion-list show-reorder="groups.showReorder" show-delete="groups.showDelete" class="">
- <div ng-repeat="(group_id, group) in groups" on-swipe-right="onSwipeRight()">
- <ion-item class="item-stable ion-star-right" ng-click="toggleGroup(group)" ng-class="{active: isGroupShown(group)}">
- <i class="icon" ng-class="isGroupShown(group) ? 'ion-minus' : 'ion-plus'"></i> Group {{group.title}}
- <button class="button button-clear icon ion-star button-assertive" ng-click="toggleStar(group)" ng-show="group.star"></button>
- <ion-option-button class="button-energized" ng-click="toggleStar(group)">
- <i class="icon ion-star margin-center"></i>
- </ion-option-button>
- <ion-option-button class="button-assertive" ng-click="onItemDelete(group_id)">
- <i class="icon ion-minus-circled margin-center"></i>
- </ion-option-button>
- <!-- <ion-delete-button class="ion-minus-circled" ng-click="onItemDelete(group_id)"></ion-delete-button> -->
- <ion-reorder-button class="ion-navicon" on-reorder="moveItem(group, $fromIndex, $toIndex)"></ion-reorder-button>
- </ion-item>
- <ion-item class="item-accordion" ng-repeat="(pad_id, item) in group.pads" ng-show="isGroupShown(group)">
- {{item.title}}
- <button class="pad-edit-btn" ui-sref="editPad({id:'{{item.id}}', title:'{{item.title}}', body:'{{item.body}}'})">Edit</button>
- </ion-item>
- </div>
- </ion-list>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement