Beispiel #1
0
        private async Task HandleEditButton()
        {
            try
            {
                var page = ViewModel.CurrentWikiPage(Web.Url.AbsoluteString);
                var wiki = await Task.Run(() => ViewModel.GetApplication().Client.Users[ViewModel.Username].Repositories[ViewModel.Repository].Wikis[page].GetInfo());

                var composer = new Composer {
                    Title = "Edit" + Title, Text = wiki.Data
                };
                composer.NewComment(this, async(text) => {
                    try
                    {
                        await composer.DoWorkAsync("Saving...", () => Task.Run(() => ViewModel.GetApplication().Client.Users[ViewModel.Username].Repositories[ViewModel.Repository].Wikis[page].Update(text, Uri.UnescapeDataString("/" + page))));
                        composer.CloseComposer();
                        Refresh();
                    }
                    catch (Exception ex)
                    {
                        AlertDialogService.ShowAlert("Unable to update page!", ex.Message);
                        composer.EnableSendButton = true;
                    };
                });
            }
            catch (Exception e)
            {
                AlertDialogService.ShowAlert("Error", e.Message);
            }
        }
Beispiel #2
0
        private void ShowCommentComposer(int line)
        {
            var composer = new Composer();

            composer.NewComment(this, (text) => {
                composer.DoWork(() => {
                    var c = Application.Client.Execute(Application.Client.Users[_user].Repositories[_slug].Commits[_branch].Comments.Create(text, _commit.Filename, line)).Data;

                    //This will inheriently add it to the controller's comments which we're referencing
                    if (Comments != null)
                    {
                        Comments.Add(c);
                    }

                    var a = new List <CommentModel>();
                    a.Add(c);
                    AddComments(a);

                    InvokeOnMainThread(() => composer.CloseComposer());
                }, ex => {
                    MonoTouch.Utilities.ShowAlert("Unable to Comment".t(), ex.Message);
                    composer.EnableSendButton = true;
                });
            });
        }
Beispiel #3
0
        private void ChangeDescription()
        {
            var composer = new Composer {
                Title = "Description", Text = ViewModel.Description
            };

            composer.NewComment(this, (text) => {
                ViewModel.Description = text;
                composer.CloseComposer();
            });
        }
Beispiel #4
0
        private void ShowCommentComposer(int?lineFrom, int?lineTo)
        {
            var composer = new Composer();

            composer.NewComment(this, async(text) => {
                try
                {
                    await composer.DoWorkAsync("Commenting...", () => ViewModel.PostComment(text, lineFrom, lineTo));
                    composer.CloseComposer();
                }
                catch (Exception e)
                {
                    MonoTouch.Utilities.ShowAlert("Unable to Comment", e.Message);
                    composer.EnableSendButton = true;
                }
            });
        }
Beispiel #5
0
        void AddCommentTapped()
        {
            var composer = new Composer();

            composer.NewComment(this, async(text) => {
                try
                {
                    await composer.DoWorkAsync("Commenting...", () => ViewModel.AddComment(text));
                    composer.CloseComposer();
                }
                catch (Exception e)
                {
                    MonoTouch.Utilities.ShowAlert("Unable to post comment!", e.Message);
                }
                finally
                {
                    composer.EnableSendButton = true;
                }
            });
        }
Beispiel #6
0
        void AddCommentTapped()
        {
            var composer = new Composer();

            composer.NewComment(this, (text) => {
                try
                {
                    composer.DoWorkTest("Commenting...".t(), async() => {
                        await ViewModel.AddComment(text);
                        composer.CloseComposer();
                    });
                }
                catch (Exception ex)
                {
                    Utilities.ShowAlert("Unable to post comment!", ex.Message);
                }
                finally
                {
                    composer.EnableSendButton = true;
                }
            });
        }
Beispiel #7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _hud = this.CreateHud();

            NavigationItem.RightBarButtonItem = new UIBarButtonItem(Theme.CurrentTheme.SaveButton, UIBarButtonItemStyle.Plain, (s, e) => {
                View.EndEditing(true);
                ViewModel.SaveCommand.Execute(null);
            });

            var title = new InputElement("Title", string.Empty, string.Empty)
            {
                TextAlignment = UITextAlignment.Right
            };

            title.Changed += (object sender, EventArgs e) => ViewModel.Title = title.Value;

            var assignedTo = new StyledStringElement("Responsible", "Unassigned", UITableViewCellStyle.Value1);

            assignedTo.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            assignedTo.Tapped   += () => ViewModel.GoToAssigneeCommand.Execute(null);

            var kind = new StyledStringElement("Issue Type", ViewModel.Kind, UITableViewCellStyle.Value1);

            kind.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            kind.Tapped   += () =>
            {
                var ctrl = new IssueAttributesView(IssueModifyViewModel.Kinds, ViewModel.Kind)
                {
                    Title = "Issue Type"
                };
                ctrl.SelectedValue = x => ViewModel.Kind = x.ToLower();
                NavigationController.PushViewController(ctrl, true);
            };

            var priority = new StyledStringElement("Priority", ViewModel.Priority, UITableViewCellStyle.Value1);

            priority.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            priority.Tapped   += () =>
            {
                var ctrl = new IssueAttributesView(IssueModifyViewModel.Priorities, ViewModel.Priority)
                {
                    Title = "Priority"
                };
                ctrl.SelectedValue = x => ViewModel.Priority = x.ToLower();
                NavigationController.PushViewController(ctrl, true);
            };

            var milestone = new StyledStringElement("Milestone".t(), "None", UITableViewCellStyle.Value1);

            milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            milestone.Tapped   += () => ViewModel.GoToMilestonesCommand.Execute(null);

            var component = new StyledStringElement("Component".t(), "None", UITableViewCellStyle.Value1);

            component.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            component.Tapped   += () => ViewModel.GoToComponentsCommand.Execute(null);

            var version = new StyledStringElement("Version".t(), "None", UITableViewCellStyle.Value1);

            version.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            version.Tapped   += () => ViewModel.GoToVersionsCommand.Execute(null);

            var content = new MultilinedElement("Description");

            content.Tapped += () =>
            {
                var composer = new Composer {
                    Title = "Issue Description", Text = content.Value
                };
                composer.NewComment(this, (text) => {
                    ViewModel.Content = text;
                    composer.CloseComposer();
                });
            };

            ViewModel.Bind(x => x.IsSaving, x =>
            {
                if (x)
                {
                    _hud.Show("Saving...");
                }
                else
                {
                    _hud.Hide();
                }
            });

            Root = new RootElement(Title)
            {
                new Section {
                    title, assignedTo, kind, priority
                }, new Section {
                    milestone, component, version
                }, new Section {
                    content
                }
            };

            ViewModel.Bind(x => x.Title, x => {
                title.Value = x;
                Root.Reload(title, UITableViewRowAnimation.None);
            }, true);

            ViewModel.Bind(x => x.AssignedTo, x => {
                assignedTo.Value = x == null ? "Unassigned" : x.Username;
                Root.Reload(assignedTo, UITableViewRowAnimation.None);
            }, true);

            ViewModel.Bind(x => x.Kind, x => {
                kind.Value = x;
                Root.Reload(kind, UITableViewRowAnimation.None);
            }, true);

            ViewModel.Bind(x => x.Priority, x => {
                priority.Value = x;
                Root.Reload(priority, UITableViewRowAnimation.None);
            }, true);

            ViewModel.Bind(x => x.Milestone, x => {
                milestone.Value = x ?? "None";
                Root.Reload(milestone, UITableViewRowAnimation.None);
            }, true);

            ViewModel.Bind(x => x.Component, x => {
                component.Value = x ?? "None";
                Root.Reload(component, UITableViewRowAnimation.None);
            }, true);

            ViewModel.Bind(x => x.Version, x => {
                version.Value = x ?? "None";
                Root.Reload(version, UITableViewRowAnimation.None);
            }, true);

            ViewModel.Bind(x => x.Content, x => {
                content.Value = x;
                Root.Reload(content, UITableViewRowAnimation.None);
            }, true);
        }
        private void PopulateRoot()
        {
            _title = new InputElement("Title", string.Empty, string.Empty);

            _assignedTo = new StyledElement("Responsible", Unassigned, UITableViewCellStyle.Value1)
            {
                Accessory = UITableViewCellAccessory.DisclosureIndicator,
            };
            _assignedTo.Tapped += () =>
            {
                var privileges = new PrivilegesController
                                     {
                                         Username = Username,
                                         RepoSlug = RepoSlug,
                                         Primary = new UserModel { Username = Username },
                                         Title = _assignedTo.Caption,
                                     };
                privileges.SelectedItem += obj =>
                {
                    _assignedTo.Value = obj.Username;
                    NavigationController.PopViewControllerAnimated(true);
                };
                NavigationController.PushViewController(privileges, true);
            };

            _issueType = CreateEnumElement("Issue Type", Kinds[0], Kinds);
            _priority = CreateEnumElement("Priority", Priorities[0], Priorities);

            _content = new MultilinedElement("Description");
            _content.Tapped += () =>
            {
                var composer = new Composer { Title = "Issue Description", Text = _content.Value, ActionButtonText = "Save" };
                composer.NewComment(this, () =>
                {
                    var text = composer.Text;
                    _content.Value = text;
                    composer.CloseComposer();
                });
            };

            var root = new RootElement(Title) { new Section { _title, _assignedTo, _issueType, _priority }, new Section { _content } };

            //See if it's an existing issue or not...
            if (ExistingIssue != null)
            {
                _title.Value = ExistingIssue.Title;
                if (ExistingIssue.Responsible != null)
                    _assignedTo.Value = ExistingIssue.Responsible.Username;
                _issueType.Value = ExistingIssue.Metadata.Kind;
                _priority.Value = ExistingIssue.Priority;
                if (!string.IsNullOrEmpty(ExistingIssue.Content))
                    _content.Value = ExistingIssue.Content;

                _status = CreateEnumElement("Status", ExistingIssue.Status, Statuses);

                //Insert the status thing inbetween title and assigned to elements
                root[0].Insert(1, _status);

                var deleteButton = new StyledElement("Delete Issue", () =>
                {
                    var alert = new UIAlertView
                                    {
                                        Title = "Are you sure?",
                                        Message = "You are about to permanently delete issue #" + ExistingIssue.LocalId + "."
                                    };
                    alert.CancelButtonIndex = alert.AddButton("Cancel");
                    var ok = alert.AddButton("Delete");

                    alert.Clicked += (sender, e) =>
                    {
                        if (e.ButtonIndex == ok)
                            DeleteIssue();
                    };

                    alert.Show();
                }, Images.BinClosed)
                {
                    Accessory = UITableViewCellAccessory.None,
                    BackgroundColor = UIColor.FromPatternImage(Images.TableCellRed),
                    TextColor = UIColor.FromRGB(0.9f, 0.30f, 0.30f)
                };
                root.Add(new Section { deleteButton });
            }

            Root = root;
        }
		private void ShowCommentComposer(int? lineFrom, int? lineTo)
        {
            var composer = new Composer();
			composer.NewComment(this, async (text) => {
				try
				{
					await composer.DoWorkAsync("Commenting...", () => ViewModel.PostComment(text, lineFrom, lineTo));
					composer.CloseComposer();
				}
				catch (Exception e)
				{
					MonoTouch.Utilities.ShowAlert("Unable to Comment".t(), e.Message);
					composer.EnableSendButton = true;
				}
            });
        }
Beispiel #10
0
 private void ChangeDescription()
 {
     var composer = new Composer { Title = "Description", Text = ViewModel.Description };
     composer.NewComment(this, (text) => {
         ViewModel.Description = text;
         composer.CloseComposer();
     });
 }
        private void HandleEditButton()
        {
            try
            {
                var page = CurrentWikiPage(Web.Request);
                var wiki = Application.Client.Users[_user].Repositories[_slug].Wikis[page].GetInfo();

                var composer = new Composer { Title = "Edit " + Title, Text = wiki.Data, ActionButtonText = "Save" };
                composer.NewComment(this, () => {
                    var text = composer.Text;

                    composer.DoWork(() => {
                        Application.Client.Users[_user].Repositories[_slug].Wikis[page].Update(text, Uri.UnescapeDataString("/" + page));

                        InvokeOnMainThread(() => {
                            composer.CloseComposer();
                            Refresh();
                        });
                    }, ex =>
                    {
                        Utilities.ShowAlert("Unable to update page!", ex.Message);
                        composer.EnableSendButton = true;
                    });
                });
            }
            catch (Exception e)
            {
                Utilities.ShowAlert("Error", e.Message);
            }
        }
        void AddCommentTapped()
        {
            var composer = new Composer();
            composer.NewComment(this, () =>
            {
                var comment = new CommentModel { Content = composer.Text };

                composer.DoWork(() =>
                {
                    Application.Client.Users[User].Repositories[Slug].Issues[Id].Comments.Create(comment);

                    InvokeOnMainThread(() =>
                    {
                        composer.CloseComposer();
                        _scrollToLastComment = true;
                        Model = null;
                        UpdateAndRender();
                    });
                }, ex =>
                {
                    Utilities.ShowAlert("Unable to post comment!", ex.Message);
                    composer.EnableSendButton = true;
                });
            });
        }
        private void PopulateRoot()
        {
            _title = new InputElement("Title", string.Empty, string.Empty);

            _assignedTo           = new StyledStringElement("Responsible", Unassigned, UITableViewCellStyle.Value1);
            _assignedTo.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            _assignedTo.Tapped   += () => {
                var p = new IssueAssigneesViewController(Username, RepoSlug);
                p.SelectedUser = (x) => {
                    _selectedAssignee = x;
                    NavigationController.PopViewControllerAnimated(true);
                };
                NavigationController.PushViewController(p, true);
            };

            _milestone           = new StyledStringElement("Milestone".t(), None, UITableViewCellStyle.Value1);
            _milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            _milestone.Tapped   += () => {
                var p = new IssueMilestonesViewController(Username, RepoSlug);
                p.MilestoneSelected = (x) => {
                    _selectedMilestone = x;
                    NavigationController.PopViewControllerAnimated(true);
                };
                NavigationController.PushViewController(p, true);
            };

            _labels           = new StyledStringElement("Labels".t(), None, UITableViewCellStyle.Value1);
            _labels.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            _labels.Tapped   += () => {
                var p = new IssueLabelsViewController(Username, RepoSlug)
                {
                    SelectedLabels = _selectedLabels
                };
                NavigationController.PushViewController(p, true);
            };

            _state = new TrueFalseElement("Open", true);

            _content         = new MultilinedElement("Description");
            _content.Tapped += () =>
            {
                var composer = new Composer {
                    Title = "Issue Description", Text = _content.Value, ActionButtonText = "Save"
                };
                composer.NewComment(this, (text) => {
                    _content.Value = text;
                    composer.CloseComposer();
                });
            };

            var root = new RootElement(Title)
            {
                new Section {
                    _title, _assignedTo, _milestone, _labels
                }, new Section {
                    _content
                }
            };

            //See if it's an existing issue or not...
            if (ExistingIssue != null)
            {
                _title.Value       = ExistingIssue.Title;
                _selectedAssignee  = ExistingIssue.Assignee;
                _selectedMilestone = ExistingIssue.Milestone;
                _selectedLabels    = ExistingIssue.Labels;
                _content.Value     = ExistingIssue.Body;
                _state.Value       = ExistingIssue.State.Equals("open");

                //Insert the status thing inbetween title and assigned to elements
                root.Insert(1, new Section()
                {
                    _state
                });
            }

            Root = root;
        }
Beispiel #14
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var save = NavigationItem.RightBarButtonItem = new UIBarButtonItem {
                Image = Images.Buttons.Save
            };

            var title = new EntryElement("Title", string.Empty, string.Empty)
            {
                TextAlignment = UITextAlignment.Right
            };
            var assignedTo = new StringElement("Responsible", "Unassigned", UITableViewCellStyle.Value1);
            var kind       = new StringElement("Issue Type", ViewModel.Kind, UITableViewCellStyle.Value1);
            var priority   = new StringElement("Priority", ViewModel.Priority, UITableViewCellStyle.Value1);
            var milestone  = new StringElement("Milestone", "None", UITableViewCellStyle.Value1);
            var component  = new StringElement("Component", "None", UITableViewCellStyle.Value1);
            var version    = new StringElement("Version", "None", UITableViewCellStyle.Value1);
            var content    = new MultilinedElement("Description");

            Root.Reset(new Section {
                title, assignedTo, kind, priority
            }, new Section {
                milestone, component, version
            }, new Section {
                content
            });

            OnActivation(d =>
            {
                d(ViewModel.Bind(x => x.IsSaving).SubscribeStatus("Saving..."));

                d(ViewModel.Bind(x => x.Title).Subscribe(x => title.Value           = x));
                d(ViewModel.Bind(x => x.AssignedTo).Subscribe(x => assignedTo.Value = x == null ? "Unassigned" : x.Username));

                d(ViewModel.Bind(x => x.Kind, true).Subscribe(x => kind.Value           = x));
                d(ViewModel.Bind(x => x.Priority, true).Subscribe(x => priority.Value   = x));
                d(ViewModel.Bind(x => x.Milestone, true).Subscribe(x => milestone.Value = x ?? "None"));
                d(ViewModel.Bind(x => x.Component, true).Subscribe(x => component.Value = x ?? "None"));
                d(ViewModel.Bind(x => x.Version, true).Subscribe(x => version.Value     = x ?? "None"));
                d(ViewModel.Bind(x => x.Content, true).Subscribe(x => version.Value     = x));

                d(title.Changed.Subscribe(x => ViewModel.Title = x));
                d(version.Clicked.BindCommand(ViewModel.GoToVersionsCommand));
                d(assignedTo.Clicked.BindCommand(ViewModel.GoToAssigneeCommand));
                d(milestone.Clicked.BindCommand(ViewModel.GoToMilestonesCommand));
                d(component.Clicked.BindCommand(ViewModel.GoToComponentsCommand));

                d(save.GetClickedObservable().Subscribe(_ => {
                    View.EndEditing(true);
                    ViewModel.SaveCommand.Execute(null);
                }));

                d(content.Clicked.Subscribe(_ =>
                {
                    var composer = new Composer {
                        Title = "Issue Description", Text = ViewModel.Content
                    };
                    composer.NewComment(this, (text) => {
                        ViewModel.Content = text;
                        composer.CloseComposer();
                    });
                }));

                d(priority.Clicked.Subscribe(_ =>
                {
                    var ctrl = new IssueAttributesView(IssueModifyViewModel.Priorities, ViewModel.Priority)
                    {
                        Title = "Priority"
                    };
                    ctrl.SelectedValue = x => ViewModel.Priority = x.ToLower();
                    NavigationController.PushViewController(ctrl, true);
                }));

                d(kind.Clicked.Subscribe(_ =>
                {
                    var ctrl = new IssueAttributesView(IssueModifyViewModel.Kinds, ViewModel.Kind)
                    {
                        Title = "Issue Type"
                    };
                    ctrl.SelectedValue = x => ViewModel.Kind = x.ToLower();
                    NavigationController.PushViewController(ctrl, true);
                }));
            });
        }