Esempio n. 1
0
        public async Task Init()
        {
            IsLoading = true;

            if (timeEntryList == null)
            {
                timeEntryList = await TimeEntryGroup.GetTimeEntryDataList(timeEntryIds);
            }

            // Create model.
            if (timeEntryList.Count > 1)
            {
                model = new TimeEntryGroup(timeEntryList);
            }
            else if (timeEntryList.Count == 1)
            {
                model = new TimeEntryModel(timeEntryList [0]);
            }

            await model.LoadAsync();

            if (model.Workspace == null || model.Workspace.Id == Guid.Empty)
            {
                model = null;
            }

            IsLoading = false;
        }
Esempio n. 2
0
        public async void Init()
        {
            IsLoading = true;

            // Create workspace.
            workspace = new WorkspaceModel(workspaceId);

            // Create model.
            if (timeEntryList.Count > 1)
            {
                Model = new TimeEntryGroup(timeEntryList);
            }
            else if (timeEntryList.Count == 1)
            {
                Model = new TimeEntryModel(timeEntryList [0]);
            }

            // Load models.
            if (timeEntryList.Count > 1)
            {
                await Task.WhenAll(workspace.LoadAsync(), Model.LoadAsync());
            }
            else
            {
                await workspace.LoadAsync();
            }

            IsLoading = false;
        }
Esempio n. 3
0
        public async void Init()
        {
            IsLoading = true;

            // Create list manager.
            tagList = new WorkspaceTagsView(workspaceId);

            // Create model.
            if (timeEntryList.Count > 1)
            {
                Model = new TimeEntryGroup(timeEntryList);
            }
            else if (timeEntryList.Count == 1)
            {
                Model = new TimeEntryModel(timeEntryList [0]);
            }

            // Create tag list.
            var dataStore = ServiceContainer.Resolve <IDataStore> ();

            modelTags = new List <TimeEntryTagData> ();

            foreach (var timeEntryData in timeEntryList)
            {
                var tags = await dataStore.Table <TimeEntryTagData> ()
                           .QueryAsync(r => r.TimeEntryId == timeEntryData.Id && r.DeletedAt == null);

                modelTags.AddRange(tags);
            }

            Model.PropertyChanged += OnModelPropertyChanged;
            IsLoading              = false;
        }
Esempio n. 4
0
 public void Update(TimeEntryGroup entryGroup)
 {
     for (int i = 0; i < dataObjects.Count; i++)
     {
         if (dataObjects[i].Data.Matches(entryGroup.Data))
         {
             dataObjects [i] = entryGroup;
         }
     }
 }
Esempio n. 5
0
        public async static Task <IList <TimeEntryData> > GetIntentTimeEntryData(Android.Content.Intent intent)
        {
            var guids = intent.GetStringArrayListExtra(ExtraGroupedTimeEntriesGuids);

            if (guids == null || guids.Count == 0)
            {
                return(new List <TimeEntryData> ());
            }

            var timeEntryList = await TimeEntryGroup.GetTimeEntryDataList(guids);

            return(timeEntryList);
        }
Esempio n. 6
0
        public async static Task <IList <TimeEntryData> > GetIntentTimeEntryData(Android.Content.Intent intent)
        {
            var extras = intent.Extras;

            if (extras == null)
            {
                return(new List <TimeEntryData> ());
            }

            // Get TimeEntryData from intent.
            var extraGuids    = extras.GetStringArrayList(ExtraTimeEntriesIds);
            var timeEntryList = await TimeEntryGroup.GetTimeEntryDataList(extraGuids);

            return(timeEntryList);
        }
        public override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            if (viewModel == null)
            {
                var timeEntryList = await TimeEntryGroup.GetTimeEntryDataList(TimeEntryIds);

                viewModel = new CreateTagViewModel(WorkspaceId, timeEntryList);
            }
            viewModel.OnIsLoadingChanged += OnModelLoaded;
            viewModel.Init();

            ValidateTagName();
        }
Esempio n. 8
0
        private async Task RemoveItemPermanentlyAsync(TimeEntryHolder holder)
        {
            if (holder == null)
            {
                return;
            }

            if (holder.TimeEntryDataList.Count > 1)
            {
                var timeEntryGroup = new TimeEntryGroup(holder.TimeEntryDataList);
                await timeEntryGroup.DeleteAsync();
            }
            else
            {
                await TimeEntryModel.DeleteTimeEntryDataAsync(holder.TimeEntryDataList.First());
            }
        }
Esempio n. 9
0
        private int GetEntryGroupIndex(TimeEntryGroup entryGroup)
        {
            int count = 0;

            foreach (var grp in dateGroups)
            {
                count++;
                // Iterate by entry list.
                foreach (var obj in grp.TimeEntryGroupList)
                {
                    if (entryGroup.Data.Matches(obj.Data))
                    {
                        return(count);
                    }
                    count++;
                }
            }
            return(-1);
        }
        public async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            if (viewModel == null)
            {
                var timeEntryList = await TimeEntryGroup.GetTimeEntryDataList(TimeEntryIds);

                viewModel = new TagListViewModel(WorkspaceId, timeEntryList);
            }

            viewModel.OnIsLoadingChanged += OnModelLoaded;
            viewModel.Init();

            if (viewModel.Model.Workspace == null || viewModel.Model.Workspace.Id == Guid.Empty)
            {
                Dismiss();
            }
        }
Esempio n. 11
0
        private TimeEntryGroup GetSuitableEntryGroupFor(DateGroup dateGroup, TimeEntryData dataObject, out bool isNewEntryGroup)
        {
            isNewEntryGroup = false;

            foreach (var grp in dateGroup.TimeEntryGroupList)
            {
                if (grp.CanContain(dataObject))
                {
                    return(grp);
                }
            }

            var entryGroup = new TimeEntryGroup(dataObject);

            dateGroup.Add(entryGroup);
            isNewEntryGroup = true;

            return(entryGroup);
        }
Esempio n. 12
0
        private TimeEntryGroup GetExistingEntryGroupFor(DateGroup dateGroup, TimeEntryData dataObject, out bool isNewEntryGroup)
        {
            isNewEntryGroup = false;

            foreach (var grp in dateGroup.TimeEntryGroupList)
            {
                TimeEntryData entryData;
                if (grp.Contains(dataObject, out entryData))
                {
                    return(grp);
                }
            }

            var entryGroup = new TimeEntryGroup(dataObject);

            dateGroup.Add(entryGroup);
            isNewEntryGroup = true;

            return(entryGroup);
        }
Esempio n. 13
0
        protected async override Task AddTimeEntryHolderAsync(TimeEntryHolder holder)
        {
            var entryGroup = new TimeEntryGroup(holder.TimeEntryDataList);

            bool      isNewGroup;
            DateGroup grp = GetDateGroupFor(entryGroup.Data, out isNewGroup);

            grp.Add(entryGroup);
            Sort();

            // Update Date group.
            var groupIndex  = GetDateGroupIndex(grp);
            var groupAction = isNewGroup ? NotifyCollectionChangedAction.Add : NotifyCollectionChangedAction.Replace;

            await UpdateCollectionAsync(grp, groupAction, groupIndex);

            // Add time entry group.
            var newIndex = GetEntryGroupIndex(entryGroup);

            await UpdateCollectionAsync(entryGroup, NotifyCollectionChangedAction.Add, newIndex);
        }
Esempio n. 14
0
        public async Task SaveProjectModel()
        {
            // Save new project.
            await model.SaveAsync();

            // Create an extra model for Project / User relationship
            var userData = ServiceContainer.Resolve <AuthManager> ().User;
            var userId   = userData != null ? userData.Id : (Guid?)null;

            if (userId.HasValue)
            {
                var projectUserModel = new ProjectUserModel();
                projectUserModel.Project = model;
                projectUserModel.User    = new UserModel(userId.Value);
                await projectUserModel.SaveAsync();
            }

            // Update entry list.
            var timeEntryGroup = new TimeEntryGroup(timeEntryList);

            timeEntryGroup.Project   = model;
            timeEntryGroup.Workspace = workspaceModel;
            await timeEntryGroup.SaveAsync();
        }
Esempio n. 15
0
 public void Remove(TimeEntryGroup entryGroup)
 {
     entryGroup.Dispose();
     dataObjects.Remove(entryGroup);
 }
Esempio n. 16
0
 public void Add(TimeEntryGroup entryGroup)
 {
     dataObjects.Add(entryGroup);
 }
Esempio n. 17
0
 public GroupedEditAdapter(TimeEntryGroup entryGroup)
 {
     this.entryGroup = entryGroup;
 }
Esempio n. 18
0
        private bool FindExistingEntry(TimeEntryData dataObject, out DateGroup dateGroup, out TimeEntryGroup existingGroup, out TimeEntryData existingEntry)
        {
            foreach (var grp in dateGroups)
            {
                foreach (var obj in grp.TimeEntryGroupList)
                {
                    TimeEntryData entry;
                    if (obj.Contains(dataObject, out entry))
                    {
                        dateGroup     = grp;
                        existingGroup = obj;
                        existingEntry = entry;
                        return(true);
                    }
                }
            }

            existingEntry = null;
            dateGroup     = null;
            existingGroup = null;
            return(false);
        }