From 17dcf475465284a8e4f0850e63893b31e9c4e804 Mon Sep 17 00:00:00 2001 From: "Hendy@Blueberry" Date: Fri, 25 May 2012 19:50:54 -0100 Subject: [PATCH] migrated in the RelationTypes package - converting it's namespace to umbraco.cms.presentation.Trees.RelationTypes --- .../presentation/umbraco.presentation.csproj | 31 ++ .../Trees/RelationTypes/EditRelationType.aspx | 147 +++++++++ .../RelationTypes/EditRelationType.aspx.cs | 285 ++++++++++++++++++ .../EditRelationType.aspx.designer.cs | 249 +++++++++++++++ .../RelationTypes/Images/Bidirectional.png | Bin 0 -> 421 bytes .../RelationTypes/Images/ParentToChild.png | Bin 0 -> 434 bytes .../Trees/RelationTypes/Images/Refresh.gif | Bin 0 -> 1053 bytes .../Trees/RelationTypes/NewRelationType.aspx | 62 ++++ .../RelationTypes/NewRelationType.aspx.cs | 110 +++++++ .../NewRelationType.aspx.designer.cs | 168 +++++++++++ .../Trees/RelationTypes/ReadOnlyRelation.cs | 56 ++++ .../RelationTypes/RegisterRelationTypeTree.cs | 28 ++ .../Trees/RelationTypes/RelationTypeTree.cs | 101 +++++++ .../RelationTypesWebService.asmx | 1 + .../RelationTypesWebService.asmx.cs | 35 +++ .../TreeMenu/ActionDeleteRelationType.cs | 85 ++++++ .../TreeMenu/ActionDeleteRelationType.js | 21 ++ .../TreeMenu/ActionNewRelationType.cs | 85 ++++++ .../TreeMenu/ActionNewRelationType.js | 3 + umbraco/presentation/web.config | 4 +- 20 files changed, 1469 insertions(+), 2 deletions(-) create mode 100644 umbraco/presentation/umbraco/Trees/RelationTypes/EditRelationType.aspx create mode 100644 umbraco/presentation/umbraco/Trees/RelationTypes/EditRelationType.aspx.cs create mode 100644 umbraco/presentation/umbraco/Trees/RelationTypes/EditRelationType.aspx.designer.cs create mode 100644 umbraco/presentation/umbraco/Trees/RelationTypes/Images/Bidirectional.png create mode 100644 umbraco/presentation/umbraco/Trees/RelationTypes/Images/ParentToChild.png create mode 100644 umbraco/presentation/umbraco/Trees/RelationTypes/Images/Refresh.gif create mode 100644 umbraco/presentation/umbraco/Trees/RelationTypes/NewRelationType.aspx create mode 100644 umbraco/presentation/umbraco/Trees/RelationTypes/NewRelationType.aspx.cs create mode 100644 umbraco/presentation/umbraco/Trees/RelationTypes/NewRelationType.aspx.designer.cs create mode 100644 umbraco/presentation/umbraco/Trees/RelationTypes/ReadOnlyRelation.cs create mode 100644 umbraco/presentation/umbraco/Trees/RelationTypes/RegisterRelationTypeTree.cs create mode 100644 umbraco/presentation/umbraco/Trees/RelationTypes/RelationTypeTree.cs create mode 100644 umbraco/presentation/umbraco/Trees/RelationTypes/RelationTypesWebService.asmx create mode 100644 umbraco/presentation/umbraco/Trees/RelationTypes/RelationTypesWebService.asmx.cs create mode 100644 umbraco/presentation/umbraco/Trees/RelationTypes/TreeMenu/ActionDeleteRelationType.cs create mode 100644 umbraco/presentation/umbraco/Trees/RelationTypes/TreeMenu/ActionDeleteRelationType.js create mode 100644 umbraco/presentation/umbraco/Trees/RelationTypes/TreeMenu/ActionNewRelationType.cs create mode 100644 umbraco/presentation/umbraco/Trees/RelationTypes/TreeMenu/ActionNewRelationType.js diff --git a/umbraco/presentation/umbraco.presentation.csproj b/umbraco/presentation/umbraco.presentation.csproj index f8402f2668..e9d269ca93 100644 --- a/umbraco/presentation/umbraco.presentation.csproj +++ b/umbraco/presentation/umbraco.presentation.csproj @@ -1415,6 +1415,29 @@ + + EditRelationType.aspx + ASPXCodeBehind + + + EditRelationType.aspx + + + NewRelationType.aspx + ASPXCodeBehind + + + NewRelationType.aspx + + + + + RelationTypesWebService.asmx + Component + + + + @@ -1703,6 +1726,14 @@ + + + + + + + + diff --git a/umbraco/presentation/umbraco/Trees/RelationTypes/EditRelationType.aspx b/umbraco/presentation/umbraco/Trees/RelationTypes/EditRelationType.aspx new file mode 100644 index 0000000000..cf9514cffb --- /dev/null +++ b/umbraco/presentation/umbraco/Trees/RelationTypes/EditRelationType.aspx @@ -0,0 +1,147 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EditRelationType.aspx.cs" Inherits="umbraco.cms.presentation.Trees.RelationTypes.EditRelationType" MasterPageFile="/umbraco/masterpages/umbracoPage.Master" %> +<%@ Register TagPrefix="umb" Namespace="umbraco.uicontrols" Assembly="controls" %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 Parent  ChildCreatedComment
 <%# DataBinder.Eval(Container.DataItem, "ParentText") %>  <%# DataBinder.Eval(Container.DataItem, "ChildText") %><%# DataBinder.Eval(Container.DataItem, "DateTime") %><%# DataBinder.Eval(Container.DataItem, "Comment") %>
+ +
+ + +
+ +
+ + +
\ No newline at end of file diff --git a/umbraco/presentation/umbraco/Trees/RelationTypes/EditRelationType.aspx.cs b/umbraco/presentation/umbraco/Trees/RelationTypes/EditRelationType.aspx.cs new file mode 100644 index 0000000000..3eefd6ebca --- /dev/null +++ b/umbraco/presentation/umbraco/Trees/RelationTypes/EditRelationType.aspx.cs @@ -0,0 +1,285 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +using umbraco; +using umbraco.BasePages; +using umbraco.cms.businesslogic.relation; +using umbraco.cms.businesslogic.web; +using umbraco.DataLayer; +using umbraco.DataLayer.SqlHelpers.SqlServer; +using umbraco.uicontrols; + +namespace umbraco.cms.presentation.Trees.RelationTypes +{ + /// + /// Edit an existing RelationType + /// + public partial class EditRelationType : UmbracoEnsuredPage + { + /// + /// Class scope reference to the current RelationType being edited + /// + private RelationType relationType = null; + + /// + /// Class scope reference to the relations associated with the current RelationType + /// + private List relations = null; + + /// + /// Umbraco ObjectType used to represent all parent items in this relation type + /// + /// + private uQuery.UmbracoObjectType parentObjectType = uQuery.UmbracoObjectType.Unknown; + + /// + /// Umbraco ObjectType used to represent all child items in this relation type + /// + private uQuery.UmbracoObjectType childObjectType = uQuery.UmbracoObjectType.Unknown; + + /// + /// Gets the name of the parent object type for all relations in this relation type + /// + protected string ParentObjectType + { + get + { + return this.parentObjectType.GetName(); //UmbracoHelper.GetName(this.parentObjectType); + } + } + + /// + /// Gets the name of the child object type for all relations in this relation type + /// + protected string ChildObjectType + { + get + { + return this.childObjectType.GetName(); //UmbracoHelper.GetName(this.childObjectType); + } + } + + /// + /// Gets a string representing the current relation type direction + /// + protected string RelationTypeDirection + { + get + { + return this.relationType.Dual == true ? "bidirectional" : "parentToChild"; + } + } + + /// + /// Gets the Relations for this RelationType, via lazy load + /// + private List Relations + { + get + { + if (this.relations == null) + { + this.relations = new List(); + + ReadOnlyRelation readOnlyRelation; + + using (IRecordsReader reader = uQuery.SqlHelper.ExecuteReader(@" + SELECT A.id, + A.parentId, + B.[text] AS 'parentText', + A.childId, + C.[text] AS 'childText', + A.relType, + A.[datetime], + A.comment + FROM umbracoRelation A + LEFT OUTER JOIN umbracoNode B ON A.parentId = B.id + LEFT OUTER JOIN umbracoNode C ON A.childId = C.id + WHERE A.relType = " + this.relationType.Id.ToString())) + { + while (reader.Read()) + { + readOnlyRelation = new ReadOnlyRelation(); + + readOnlyRelation.Id = reader.GetInt("id"); + readOnlyRelation.ParentId = reader.GetInt("parentId"); + readOnlyRelation.ParentText = reader.GetString("parentText"); + readOnlyRelation.ChildId = reader.GetInt("childId"); + readOnlyRelation.ChildText = reader.GetString("childText"); + readOnlyRelation.RelType = reader.GetInt("relType"); + readOnlyRelation.DateTime = reader.GetDateTime("datetime"); + readOnlyRelation.Comment = reader.GetString("comment"); + + this.relations.Add(readOnlyRelation); + } + } + } + + return this.relations; + } + } + + /// + /// On Load event + /// + /// this aspx page + /// EventArgs (expect empty) + protected void Page_Load(object sender, EventArgs e) + { + int id; + if (int.TryParse(Request.QueryString["id"], out id)) + { + this.relationType = new RelationType(id); + if (this.relationType != null) + { + // API doens't allow us to pull the object Type, so sql needed + // this.parentObjectType = UmbracoHelper.GetUmbracoObjectType(uQuery.SqlHelper.ExecuteScalar("SELECT parentObjectType FROM umbracoRelationType WHERE id = " + this.relationType.Id.ToString())); + // this.childObjectType = UmbracoHelper.GetUmbracoObjectType(uQuery.SqlHelper.ExecuteScalar("SELECT childObjectType FROM umbracoRelationType WHERE id = " + this.relationType.Id.ToString())); + + // uQuery has the above in a helper method, so no sql needed now + this.parentObjectType = this.relationType.GetParentUmbracoObjectType(); + this.childObjectType = this.relationType.GetChildUmbracoObjectType(); + + // ----------- + + if (!this.IsPostBack) + { + this.EnsureChildControls(); + + this.idLiteral.Text = this.relationType.Id.ToString(); + this.nameTextBox.Text = this.relationType.Name; + this.aliasTextBox.Text = this.relationType.Alias; + + if (this.relationType.Dual) + { + this.dualRadioButtonList.Items.FindByValue("1").Selected = true; + } + else + { + this.dualRadioButtonList.Items.FindByValue("0").Selected = true; + } + + this.parentLiteral.Text = this.parentObjectType.GetFriendlyName(); // UmbracoHelper.GetFriendlyName(this.parentObjectType); + this.childLiteral.Text = this.childObjectType.GetFriendlyName(); // UmbracoHelper.GetFriendlyName(this.childObjectType); + + this.relationsCountLiteral.Text = this.Relations.Count.ToString(); + + this.relationsRepeater.DataSource = this.Relations; + this.relationsRepeater.DataBind(); + } + } + else + { + throw new Exception("Unable to get RelationType where ID = " + id.ToString()); + } + } + else + { + throw new Exception("Invalid RelationType ID"); + } + } + + /// + /// Creates the child controls used in this page + /// + protected override void CreateChildControls() + { + base.CreateChildControls(); + + TabPage relationTypeTabPage = this.tabControl.NewTabPage("Relation Type"); + relationTypeTabPage.Controls.Add(this.idPane); + relationTypeTabPage.Controls.Add(this.nameAliasPane); + relationTypeTabPage.Controls.Add(this.directionPane); + relationTypeTabPage.Controls.Add(this.objectTypePane); + + MenuImageButton saveMenuImageButton = relationTypeTabPage.Menu.NewImageButton(); + saveMenuImageButton.AlternateText = "save relation type"; + saveMenuImageButton.Click += new ImageClickEventHandler(this.SaveMenuImageButton_Click); + saveMenuImageButton.ImageURL = "/umbraco/images/editor/save.gif"; + saveMenuImageButton.CausesValidation = true; + saveMenuImageButton.ValidationGroup = "RelationType"; + + TabPage relationsTabPage = this.tabControl.NewTabPage("Relations"); + relationsTabPage.Controls.Add(this.relationsCountPane); + relationsTabPage.Controls.Add(this.relationsPane); + + MenuImageButton refreshMenuImageButton = relationsTabPage.Menu.NewImageButton(); + refreshMenuImageButton.AlternateText = "refresh relations"; + refreshMenuImageButton.Click += new ImageClickEventHandler(this.RefreshMenuImageButton_Click); + refreshMenuImageButton.ImageUrl = "/umbraco/Trees/RelationTypes/Images/Refresh.gif"; + refreshMenuImageButton.CausesValidation = false; + } + + /// + /// check that alias hasn't been changed to clash with another (except itself) + /// + /// the aliasCustomValidator control + /// to set validation respose + protected void AliasCustomValidator_ServerValidate(object source, ServerValidateEventArgs args) + { + args.IsValid = (RelationType.GetByAlias(this.aliasTextBox.Text.Trim()) == null) || + (this.aliasTextBox.Text.Trim() == this.relationType.Alias); + } + + /// + /// Reload the relations, in case they have changed + /// + /// expects refreshMenuImageButton + /// expects ImageClickEventArgs + private void RefreshMenuImageButton_Click(object sender, ImageClickEventArgs e) + { + } + + /// + /// Save button in Umbraco menu + /// + /// expects saveMenuImageButton object + /// expects ImageClickEventArgs + private void SaveMenuImageButton_Click(object sender, ImageClickEventArgs e) + { + if (this.Page.IsValid) + { + bool nameChanged = this.relationType.Name != this.nameTextBox.Text.Trim(); + bool aliasChanged = this.relationType.Alias != this.aliasTextBox.Text.Trim(); + bool directionChanged = this.relationType.Dual != (this.dualRadioButtonList.SelectedValue == "1"); + + if (nameChanged || aliasChanged || directionChanged) + { + string bubbleBody = string.Empty; + + if (nameChanged) + { + bubbleBody += "Name, "; + + this.relationType.Name = this.nameTextBox.Text.Trim(); + + // Refresh tree, as the name as changed + BasePage.Current.ClientTools.SyncTree(this.relationType.Id.ToString(), true); + } + + if (directionChanged) + { + bubbleBody += "Direction, "; + this.relationType.Dual = this.dualRadioButtonList.SelectedValue == "1"; + } + + if (aliasChanged) + { + bubbleBody += "Alias, "; + this.relationType.Alias = this.aliasTextBox.Text.Trim(); + } + + bubbleBody = bubbleBody.Remove(bubbleBody.LastIndexOf(','), 1); + bubbleBody = bubbleBody + "Changed"; + + BasePage.Current.ClientTools.ShowSpeechBubble(speechBubbleIcon.save, "Relation Type Updated", bubbleBody); + } + } + } + } +} diff --git a/umbraco/presentation/umbraco/Trees/RelationTypes/EditRelationType.aspx.designer.cs b/umbraco/presentation/umbraco/Trees/RelationTypes/EditRelationType.aspx.designer.cs new file mode 100644 index 0000000000..af2030dda0 --- /dev/null +++ b/umbraco/presentation/umbraco/Trees/RelationTypes/EditRelationType.aspx.designer.cs @@ -0,0 +1,249 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace umbraco.cms.presentation.Trees.RelationTypes { + + + public partial class EditRelationType { + + /// + /// tabControl control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.TabView tabControl; + + /// + /// idPane control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.Pane idPane; + + /// + /// idPropertyPanel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel idPropertyPanel; + + /// + /// idLiteral control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal idLiteral; + + /// + /// nameAliasPane control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.Pane nameAliasPane; + + /// + /// nameProperyPanel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel nameProperyPanel; + + /// + /// nameTextBox control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox nameTextBox; + + /// + /// nameRequiredFieldValidator control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator nameRequiredFieldValidator; + + /// + /// aliasPropertyPanel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel aliasPropertyPanel; + + /// + /// aliasTextBox control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox aliasTextBox; + + /// + /// aliasRequiredFieldValidator control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator aliasRequiredFieldValidator; + + /// + /// aliasCustomValidator control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CustomValidator aliasCustomValidator; + + /// + /// directionPane control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.Pane directionPane; + + /// + /// dualPropertyPanel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel dualPropertyPanel; + + /// + /// dualRadioButtonList control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RadioButtonList dualRadioButtonList; + + /// + /// objectTypePane control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.Pane objectTypePane; + + /// + /// parentPropertyPanel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel parentPropertyPanel; + + /// + /// parentLiteral control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal parentLiteral; + + /// + /// childPropertyPanel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel childPropertyPanel; + + /// + /// childLiteral control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal childLiteral; + + /// + /// relationsCountPane control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.Pane relationsCountPane; + + /// + /// relationsCountPropertyPanel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel relationsCountPropertyPanel; + + /// + /// relationsCountLiteral control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal relationsCountLiteral; + + /// + /// relationsPane control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.Pane relationsPane; + + /// + /// relationsPropertyPanel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel relationsPropertyPanel; + + /// + /// relationsRepeater control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Repeater relationsRepeater; + } +} diff --git a/umbraco/presentation/umbraco/Trees/RelationTypes/Images/Bidirectional.png b/umbraco/presentation/umbraco/Trees/RelationTypes/Images/Bidirectional.png new file mode 100644 index 0000000000000000000000000000000000000000..4233e675daa679f1a3664d6f155e97d5c2e04a69 GIT binary patch literal 421 zcmV;W0b2fvP)F4`Ay9HWgAIsx;|do4neMwiCpxm>3^t(V+l7ZyzvEH>)coD4!}>N>d7$Qt-DeyA zx1X%}pRptMf6~T?|1m3r|A#H~{SUPHKTz}kq{UJHW9EkbH?7dWi0<^0U1#e5ufDP9 z|MF||{x7~V>;L>q)BevoKl%UEGkyOjoa+4FeZ2L5`_ab#O^0g#2Tb((ubHWO5^f04 z*+<$=RR3Rkbi``>V|>VM6?vj1K^ zuK!h%6_22}0_g1X)%yznHv<)=tcr#^8|df%)(xirT|4am$1RNf@7e7F(tI9kH~{^8 z6X@sfKtEfcE6^{{vH&{!J5cjYoUs7Z%m&oF1D67z<{b)gvbdvhgk}o>LvNw5y%DeF P00000NkvXXu0mjfyeiX4 literal 0 HcmV?d00001 diff --git a/umbraco/presentation/umbraco/Trees/RelationTypes/Images/ParentToChild.png b/umbraco/presentation/umbraco/Trees/RelationTypes/Images/ParentToChild.png new file mode 100644 index 0000000000000000000000000000000000000000..bd7c831ef385e4d453cdeef81f7179591fe4892e GIT binary patch literal 434 zcmV;j0ZsmiP)Px#1ZP1_K>z@;j|==^1poj5AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUy8FWQhbW?9;ba!ELWdKlNX>N2bPDNB8b~7$DE;UJt{NMlp0Sie) zK~y+TV_+BsB!z(gO!wWM6CK$|(uAxSsQJ57hxKg?14@o({0HH}!>Rvs_a*+%*b)0b zX=B9yn3ci*!xsAf2ip7}sQG`=;;8>Ib3^}|R_I?uF$AP}-L0knSKnClfBCg}{}*4G z^?&}QY5!-PpZtI7nZExMPIdn8KHmDj{b=L=rbD&=115U?*UVHs2{!~}^UCWB{x7{c z=l{aXGyc!LFy;S@a})kgKHdGl?_~S`&SOpgTMpO#Z#Y=>zh+CfN8kqF zb2iY=|E(KL|GReB|BqW3`QNkK1*G{r$pNWfpk)Dc_IIG>n9SvUW{zikIEZa#cx_lY};4*fs=xbNEQwbx#+KYZ@~ zsY~}SU4L-n&cn0Mu3me2<=&es_ny4D@#x!~XWwr<|9|)CkNYqG-+TT4+2>2ozg~Xu z{Kvx=KOVjM|K!!r=kNYKfA{~z+g~r<{e1c1-l7^8fR?HHtR*Nt1<1kvYc5qeTqrK2G!G3wX(T` zzP^0e(`>-It>i#bs#jc-Lfx-ag% +<%@ Register TagPrefix="umb" Namespace="umbraco.uicontrols" Assembly="controls" %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <% ///* */ %> + + + + + + + + + + + + + + + +
+ + or + Cancel +
+ + +
+ diff --git a/umbraco/presentation/umbraco/Trees/RelationTypes/NewRelationType.aspx.cs b/umbraco/presentation/umbraco/Trees/RelationTypes/NewRelationType.aspx.cs new file mode 100644 index 0000000000..27df27eaa1 --- /dev/null +++ b/umbraco/presentation/umbraco/Trees/RelationTypes/NewRelationType.aspx.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +using umbraco.BasePages; +using umbraco.cms.businesslogic.relation; + +namespace umbraco.cms.presentation.Trees.RelationTypes +{ + /// + /// Add a new Relation Type + /// + public partial class NewRelationType : UmbracoEnsuredPage + { + /// + /// On Load event + /// + /// this aspx page + /// EventArgs (expect empty) + protected void Page_Load(object sender, EventArgs e) + { + if (!this.Page.IsPostBack) + { + this.Form.DefaultFocus = this.descriptionTextBox.ClientID; + } + + this.AppendUmbracoObjectTypes(this.parentDropDownList); + this.AppendUmbracoObjectTypes(this.childDropDownList); + } + + /// + /// Server side validation to ensure there are no existing relationshipTypes with the alias of + /// the relation type being added + /// + /// the aliasCustomValidator control + /// to set validation respose + protected void AliasCustomValidator_ServerValidate(object source, ServerValidateEventArgs args) + { + args.IsValid = RelationType.GetByAlias(this.aliasTextBox.Text.Trim()) == null; + } + + /// + /// Add a new relation type + /// + /// expects the addButton control + /// expects EventArgs for addButton + protected void AddButton_Click(object sender, EventArgs e) + { + if (this.Page.IsValid) + { + int newRelationTypeId = uQuery.SqlHelper.ExecuteScalar( + string.Format( + "INSERT INTO umbracoRelationType (dual, parentObjectType, childObjectType, name, alias) VALUES ({0}, '{1}', '{2}', '{3}', '{4}')", + this.dualRadioButtonList.SelectedValue, + // UmbracoHelper.GetGuid(UmbracoHelper.GetUmbracoObjectType(this.parentDropDownList.SelectedValue)).ToString(), + // UmbracoHelper.GetGuid(UmbracoHelper.GetUmbracoObjectType(this.childDropDownList.SelectedValue)).ToString(), + uQuery.GetUmbracoObjectType(this.parentDropDownList.SelectedValue).GetGuid().ToString(), + uQuery.GetUmbracoObjectType(this.childDropDownList.SelectedValue).GetGuid().ToString(), + this.descriptionTextBox.Text, + this.aliasTextBox.Text.Trim()) + "; SELECT MAX (id) FROM umbracoRelationType"); + + // base.speechBubble(BasePage.speechBubbleIcon.success, "New Relation Type", "relation type created"); + + BasePage.Current.ClientTools.ChangeContentFrameUrl("/umbraco/Trees/RelationTypes/EditRelationType.aspx?id=" + newRelationTypeId.ToString()).CloseModalWindow().ChildNodeCreated(); + } + } + + /// + /// Adds the Umbraco Object types to a drop down list + /// + /// control for which to add the Umbraco object types + private void AppendUmbracoObjectTypes(DropDownList dropDownList) + { + // dropDownList.Items.Add(new ListItem(UmbracoHelper.GetFriendlyName(UmbracoHelper.UmbracoObjectType.Document), UmbracoHelper.GetName(UmbracoHelper.UmbracoObjectType.Document))); + // dropDownList.Items.Add(new ListItem(UmbracoHelper.GetFriendlyName(UmbracoHelper.UmbracoObjectType.Media), UmbracoHelper.GetName(UmbracoHelper.UmbracoObjectType.Media))); + // dropDownList.Items.Add(new ListItem(UmbracoHelper.GetFriendlyName(UmbracoHelper.UmbracoObjectType.Member), UmbracoHelper.GetName(UmbracoHelper.UmbracoObjectType.Member))); + // ////dropDownList.Items.Add(new ListItem("---", "---")); + // dropDownList.Items.Add(new ListItem(UmbracoHelper.GetFriendlyName(UmbracoHelper.UmbracoObjectType.MemberGroup), UmbracoHelper.GetName(UmbracoHelper.UmbracoObjectType.MemberGroup))); + // dropDownList.Items.Add(new ListItem(UmbracoHelper.GetFriendlyName(UmbracoHelper.UmbracoObjectType.MemberType), UmbracoHelper.GetName(UmbracoHelper.UmbracoObjectType.MemberType))); + // dropDownList.Items.Add(new ListItem(UmbracoHelper.GetFriendlyName(UmbracoHelper.UmbracoObjectType.DocumentType), UmbracoHelper.GetName(UmbracoHelper.UmbracoObjectType.DocumentType))); + // dropDownList.Items.Add(new ListItem(UmbracoHelper.GetFriendlyName(UmbracoHelper.UmbracoObjectType.MediaType), UmbracoHelper.GetName(UmbracoHelper.UmbracoObjectType.MediaType))); + // dropDownList.Items.Add(new ListItem(UmbracoHelper.GetFriendlyName(UmbracoHelper.UmbracoObjectType.ContentItem), UmbracoHelper.GetName(UmbracoHelper.UmbracoObjectType.ContentItem))); + // dropDownList.Items.Add(new ListItem(UmbracoHelper.GetFriendlyName(UmbracoHelper.UmbracoObjectType.ContentItemType), UmbracoHelper.GetName(UmbracoHelper.UmbracoObjectType.ContentItemType))); + // dropDownList.Items.Add(new ListItem(UmbracoHelper.GetFriendlyName(UmbracoHelper.UmbracoObjectType.DataType), UmbracoHelper.GetName(UmbracoHelper.UmbracoObjectType.DataType))); + // dropDownList.Items.Add(new ListItem(UmbracoHelper.GetFriendlyName(UmbracoHelper.UmbracoObjectType.RecycleBin), UmbracoHelper.GetName(UmbracoHelper.UmbracoObjectType.RecycleBin))); + // dropDownList.Items.Add(new ListItem(UmbracoHelper.GetFriendlyName(UmbracoHelper.UmbracoObjectType.ROOT), UmbracoHelper.GetName(UmbracoHelper.UmbracoObjectType.ROOT))); + // dropDownList.Items.Add(new ListItem(UmbracoHelper.GetFriendlyName(UmbracoHelper.UmbracoObjectType.Stylesheet), UmbracoHelper.GetName(UmbracoHelper.UmbracoObjectType.Stylesheet))); + // dropDownList.Items.Add(new ListItem(UmbracoHelper.GetFriendlyName(UmbracoHelper.UmbracoObjectType.Template), UmbracoHelper.GetName(UmbracoHelper.UmbracoObjectType.Template))); + + dropDownList.Items.Add(new ListItem(uQuery.UmbracoObjectType.Document.GetFriendlyName(), uQuery.UmbracoObjectType.Document.GetName())); + dropDownList.Items.Add(new ListItem(uQuery.UmbracoObjectType.Media.GetFriendlyName(), uQuery.UmbracoObjectType.Media.GetName())); + dropDownList.Items.Add(new ListItem(uQuery.UmbracoObjectType.Member.GetFriendlyName(), uQuery.UmbracoObjectType.Member.GetName())); + //////dropDownList.Items.Add(new ListItem("---", "---")); + dropDownList.Items.Add(new ListItem(uQuery.UmbracoObjectType.MemberGroup.GetFriendlyName(), uQuery.UmbracoObjectType.MemberGroup.GetName())); + dropDownList.Items.Add(new ListItem(uQuery.UmbracoObjectType.MemberType.GetFriendlyName(), uQuery.UmbracoObjectType.MemberType.GetName())); + dropDownList.Items.Add(new ListItem(uQuery.UmbracoObjectType.DocumentType.GetFriendlyName(), uQuery.UmbracoObjectType.DocumentType.GetName())); + dropDownList.Items.Add(new ListItem(uQuery.UmbracoObjectType.MediaType.GetFriendlyName(), uQuery.UmbracoObjectType.MediaType.GetName())); + dropDownList.Items.Add(new ListItem(uQuery.UmbracoObjectType.ContentItem.GetFriendlyName(), uQuery.UmbracoObjectType.ContentItem.GetName())); + dropDownList.Items.Add(new ListItem(uQuery.UmbracoObjectType.ContentItemType.GetFriendlyName(), uQuery.UmbracoObjectType.ContentItemType.GetName())); + dropDownList.Items.Add(new ListItem(uQuery.UmbracoObjectType.DataType.GetFriendlyName(), uQuery.UmbracoObjectType.DataType.GetName())); + dropDownList.Items.Add(new ListItem(uQuery.UmbracoObjectType.RecycleBin.GetFriendlyName(), uQuery.UmbracoObjectType.RecycleBin.GetName())); + dropDownList.Items.Add(new ListItem(uQuery.UmbracoObjectType.ROOT.GetFriendlyName(), uQuery.UmbracoObjectType.ROOT.GetName())); + dropDownList.Items.Add(new ListItem(uQuery.UmbracoObjectType.Stylesheet.GetFriendlyName(), uQuery.UmbracoObjectType.Stylesheet.GetName())); + dropDownList.Items.Add(new ListItem(uQuery.UmbracoObjectType.Template.GetFriendlyName(), uQuery.UmbracoObjectType.Template.GetName())); + } + } +} \ No newline at end of file diff --git a/umbraco/presentation/umbraco/Trees/RelationTypes/NewRelationType.aspx.designer.cs b/umbraco/presentation/umbraco/Trees/RelationTypes/NewRelationType.aspx.designer.cs new file mode 100644 index 0000000000..8c10eedea7 --- /dev/null +++ b/umbraco/presentation/umbraco/Trees/RelationTypes/NewRelationType.aspx.designer.cs @@ -0,0 +1,168 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace umbraco.cms.presentation.Trees.RelationTypes { + + + public partial class NewRelationType { + + /// + /// nameAliasPane control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.Pane nameAliasPane; + + /// + /// nameProperyPanel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel nameProperyPanel; + + /// + /// descriptionTextBox control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox descriptionTextBox; + + /// + /// descriptionRequiredFieldValidator control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator descriptionRequiredFieldValidator; + + /// + /// aliasPropertyPanel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel aliasPropertyPanel; + + /// + /// aliasTextBox control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox aliasTextBox; + + /// + /// aliasRequiredFieldValidator control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator aliasRequiredFieldValidator; + + /// + /// aliasCustomValidator control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CustomValidator aliasCustomValidator; + + /// + /// directionPane control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.Pane directionPane; + + /// + /// PropertyPanel1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel PropertyPanel1; + + /// + /// dualRadioButtonList control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RadioButtonList dualRadioButtonList; + + /// + /// objectTypePane control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.Pane objectTypePane; + + /// + /// PropertyPanel2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel PropertyPanel2; + + /// + /// parentDropDownList control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DropDownList parentDropDownList; + + /// + /// PropertyPanel3 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel PropertyPanel3; + + /// + /// childDropDownList control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DropDownList childDropDownList; + + /// + /// addButton control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button addButton; + } +} diff --git a/umbraco/presentation/umbraco/Trees/RelationTypes/ReadOnlyRelation.cs b/umbraco/presentation/umbraco/Trees/RelationTypes/ReadOnlyRelation.cs new file mode 100644 index 0000000000..dbc1381d68 --- /dev/null +++ b/umbraco/presentation/umbraco/Trees/RelationTypes/ReadOnlyRelation.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +using umbraco.cms.businesslogic.relation; + +namespace umbraco.cms.presentation.Trees.RelationTypes +{ + /// + /// This is used to build a collection of relations from a single sql statement, + /// as the umbraco.cms.businesslogic.relation.Relation obj will hit the DB for each instace it creates + /// + internal struct ReadOnlyRelation + { + /// + /// Gets or sets the Relation Id + /// + public int Id { get; set; } + + /// + /// Gets or sets Relation Parent Id + /// + public int ParentId { get; set; } + + /// + /// Gets or sets Relation Parent Text + /// + public string ParentText { get; set; } + + /// + /// Gets or sets Relation Child Id + /// + public int ChildId { get; set; } + + /// + /// Gets or sets Relation Child Text + /// + public string ChildText { get; set; } + + /// + /// Gets or sets Relation RelationType Id + /// + public int RelType { get; set; } + + /// + /// Gets or sets Relation DateTime + /// + public DateTime DateTime { get; set; } + + /// + /// Gets or sets Relation Comment + /// + public string Comment { get; set; } + } +} \ No newline at end of file diff --git a/umbraco/presentation/umbraco/Trees/RelationTypes/RegisterRelationTypeTree.cs b/umbraco/presentation/umbraco/Trees/RelationTypes/RegisterRelationTypeTree.cs new file mode 100644 index 0000000000..bdd0355ad5 --- /dev/null +++ b/umbraco/presentation/umbraco/Trees/RelationTypes/RegisterRelationTypeTree.cs @@ -0,0 +1,28 @@ +using umbraco.BusinessLogic; +using umbraco.cms.businesslogic; +using umbraco.cms.businesslogic.web; +using umbraco.cms.presentation.Trees; // TreeDefinitionCollection + +namespace umbraco.cms.presentation.Trees.RelationTypes +{ + /// + /// This class will dynamically register a tree without having to populate the umbracoAppTree table (RegisterRelationTypeTree.sql) + /// http://www.shazwazza.com/post/Dynamically-registering-custom-trees-without-writing-to-UmbracoAppTree.aspx + /// + public class AddRelationTypeTree : ApplicationBase + { + /// + /// Initializes a new instance of the AddRelationTypeTree class. + /// + public AddRelationTypeTree() + { + Application developerSection = Application.getByAlias("developer"); + + ApplicationTree relationTypesApplicationTree = new ApplicationTree(false, true, 1, "developer", "relationTypesTree", "Relation Types", ".sprTreeFolder", ".sprTreeFolder_0", "Umbraco.RelationTypes", "RelationTypeTree", null); + + TreeDefinition relationTypesTreeDefinition = new TreeDefinition(typeof(umbraco.cms.presentation.Trees.RelationTypes.RelationTypeTree), relationTypesApplicationTree, developerSection); + + TreeDefinitionCollection.Instance.Add(relationTypesTreeDefinition); + } + } +} \ No newline at end of file diff --git a/umbraco/presentation/umbraco/Trees/RelationTypes/RelationTypeTree.cs b/umbraco/presentation/umbraco/Trees/RelationTypes/RelationTypeTree.cs new file mode 100644 index 0000000000..9a03ee8110 --- /dev/null +++ b/umbraco/presentation/umbraco/Trees/RelationTypes/RelationTypeTree.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Web; + +using umbraco.BusinessLogic.Actions; +using umbraco.cms.businesslogic.relation; +using umbraco.cms.presentation.Trees; // BaseTree +using umbraco.DataLayer; +using umbraco.interfaces; + +using Umbraco.RelationTypes.TreeMenu; + +namespace umbraco.cms.presentation.Trees.RelationTypes +{ + /// + /// RelationTypes tree for developer section + /// http://our.umbraco.org/wiki/reference/backoffice-apis/tree-api-to-create-custom-treesapplications + /// (to comply with Umbraco naming conventions rename this class to loadRelationTypes) + /// + public class RelationTypeTree : BaseTree + { + /// + /// Initializes a new instance of the RelationTypeTree class. + /// + /// name of umbraco app to which this tree has been added, (in this case "developer") + public RelationTypeTree(string application) : base(application) + { + } + + /// + /// Builds the javascript methods for use by the nodes in this tree + /// + /// string container for javascript + public override void RenderJS(ref StringBuilder javascript) + { + javascript.Append( + @" + function openRelationType(id) { + UmbClientMgr.contentFrame('Trees/RelationTypes/EditRelationType.aspx?id=' + id); + } + "); + } + + /// + /// This is called if the tree has been expanded, and it's used to render and child nodes for this tree + /// + /// current tree + public override void Render(ref XmlTree tree) + { + XmlTreeNode node; + + foreach (RelationType relationType in RelationType.GetAll().OrderBy(relationType => relationType.Name)) + { + node = XmlTreeNode.Create(this); + node.NodeID = relationType.Id.ToString(); + node.Text = relationType.Name; + node.Icon = "settingAgent.gif"; + node.Action = "javascript:openRelationType('" + node.NodeID + "');"; + + tree.Add(node); + } + } + + /// + /// Adds right click context tree actions for each child node + /// + /// collection of actions (expected to be empty) + protected override void CreateAllowedActions(ref List actions) + { + actions.Clear(); + actions.Add(ActionDeleteRelationType.Instance); + } + + /// + /// Adds right click context tree actions for the root 'Relation Types' node + /// + /// collection of actions (expected to be empty) + protected override void CreateRootNodeActions(ref List actions) + { + actions.Clear(); + actions.Add(ActionNewRelationType.Instance); + actions.Add(ContextMenuSeperator.Instance); + actions.Add(ActionRefresh.Instance); + } + + /// + /// Configures root node 'Relation Types' properties + /// + /// the 'Relation Types' root node + protected override void CreateRootNode(ref XmlTreeNode rootNode) + { + rootNode.Text = "Relation Types"; + rootNode.Icon = BaseTree.FolderIcon; + rootNode.OpenIcon = BaseTree.FolderIconOpen; + rootNode.NodeType = this.TreeAlias; // (Was prefixed with innit) + rootNode.NodeID = "init"; + } + } +} diff --git a/umbraco/presentation/umbraco/Trees/RelationTypes/RelationTypesWebService.asmx b/umbraco/presentation/umbraco/Trees/RelationTypes/RelationTypesWebService.asmx new file mode 100644 index 0000000000..593f1f824c --- /dev/null +++ b/umbraco/presentation/umbraco/Trees/RelationTypes/RelationTypesWebService.asmx @@ -0,0 +1 @@ +<%@ WebService Language="C#" CodeBehind="RelationTypesWebService.asmx.cs" Class="umbraco.cms.presentation.Trees.RelationTypes.RelationTypesWebService" %> diff --git a/umbraco/presentation/umbraco/Trees/RelationTypes/RelationTypesWebService.asmx.cs b/umbraco/presentation/umbraco/Trees/RelationTypes/RelationTypesWebService.asmx.cs new file mode 100644 index 0000000000..148f731f69 --- /dev/null +++ b/umbraco/presentation/umbraco/Trees/RelationTypes/RelationTypesWebService.asmx.cs @@ -0,0 +1,35 @@ +using System; +using System.Web; +using System.Web.Services; + +namespace umbraco.cms.presentation.Trees.RelationTypes +{ + /// + /// Webservice to delete relation types, this allows deletion via a javacscript call hooked into the tree UI + /// + [WebService(Namespace = "http://tempuri.org/")] + [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] + [System.ComponentModel.ToolboxItem(false)] + [System.Web.Script.Services.ScriptService] // Allows this Web Service to be called from script, using ASP.NET AJAX + public class RelationTypesWebService : System.Web.Services.WebService + { + /// + /// Delete an Umbraco RelationType and all it's associated Relations + /// + /// database id of the relation type to delete + [WebMethod] + public void DeleteRelationType(int relationTypeId) + { + // Check user calling this service is of type administrator + umbraco.BusinessLogic.User user = umbraco.BusinessLogic.User.GetCurrent(); + if (user.UserType.Name == "Administrators") + { + // Delete all relations for this relation type! + uQuery.SqlHelper.ExecuteNonQuery(string.Format("DELETE FROM umbracoRelation WHERE relType = {0}", relationTypeId.ToString())); + + // Delete relation type + uQuery.SqlHelper.ExecuteNonQuery(string.Format("DELETE FROM umbracoRelationType WHERE id = {0}", relationTypeId.ToString())); + } + } + } +} diff --git a/umbraco/presentation/umbraco/Trees/RelationTypes/TreeMenu/ActionDeleteRelationType.cs b/umbraco/presentation/umbraco/Trees/RelationTypes/TreeMenu/ActionDeleteRelationType.cs new file mode 100644 index 0000000000..6fd2a7f85b --- /dev/null +++ b/umbraco/presentation/umbraco/Trees/RelationTypes/TreeMenu/ActionDeleteRelationType.cs @@ -0,0 +1,85 @@ +using System; +using umbraco; +using umbraco.interfaces; + +namespace Umbraco.RelationTypes.TreeMenu +{ + /// + /// Delete a Relation Type - an Umbraco tree context menu action + /// + public class ActionDeleteRelationType : IAction + { + /// + /// Private field for the singleton instance + /// + private static readonly ActionDeleteRelationType instance = new ActionDeleteRelationType(); + + /// + /// Gets a singleton instance of this action + /// + public static ActionDeleteRelationType Instance + { + get { return instance; } + } + + #region IAction Members + + /// + /// Gets a string alias used to identify this action + /// + public string Alias + { + get { return "delete"; } + } + + /// + /// Gets a unique char to associate with this action + /// + public char Letter + { + get { return '¤'; } + } + + /// + /// Gets a value indicating whether the Umbraco notification area is used ? + /// + public bool ShowInNotifier + { + get { return false; } + } + + /// + /// Gets a value indicating whether this action can be configured for use only by specific members + /// + public bool CanBePermissionAssigned + { + get { return false; } // Since this tree is in the developer section, no further granular permissions are required + } + + /// + /// Gets an icon to be used for the right click action + /// + public string Icon + { + get { return ".sprDelete"; } // .sprDelete refers to an existing sprite + } + + /// + /// Gets a string for the javascript source + /// + public string JsSource + { + get { return "/umbraco/Trees/RelationTypes/TreeMenu/ActionDeleteRelationType.js"; } + } + + /// + /// Gets a javascript string to execute when this action is fired + /// + public string JsFunctionName + { + get { return "javascript:actionDeleteRelationType(UmbClientMgr.mainTree().getActionNode().nodeId,UmbClientMgr.mainTree().getActionNode().nodeName);"; } + } + + #endregion + } +} diff --git a/umbraco/presentation/umbraco/Trees/RelationTypes/TreeMenu/ActionDeleteRelationType.js b/umbraco/presentation/umbraco/Trees/RelationTypes/TreeMenu/ActionDeleteRelationType.js new file mode 100644 index 0000000000..6475ec00c7 --- /dev/null +++ b/umbraco/presentation/umbraco/Trees/RelationTypes/TreeMenu/ActionDeleteRelationType.js @@ -0,0 +1,21 @@ +function actionDeleteRelationType(relationTypeId, relationTypeName) { + + if (confirm('Are you sure you want to delete "' + relationTypeName + '"?')) { + $.ajax({ + type: "POST", + url: "/umbraco/Trees/RelationTypes/RelationTypesWebService.asmx/DeleteRelationType", + data: "{ 'relationTypeId' : '" + relationTypeId + "' }", + contentType: "application/json; charset=utf-8", + dataType: "json", + success: function (data) { + UmbClientMgr.mainTree().refreshTree('relationTypesTree'); + UmbClientMgr.appActions().openDashboard('developer'); + }, + error: function (data) { } + }); + + } + +} + + diff --git a/umbraco/presentation/umbraco/Trees/RelationTypes/TreeMenu/ActionNewRelationType.cs b/umbraco/presentation/umbraco/Trees/RelationTypes/TreeMenu/ActionNewRelationType.cs new file mode 100644 index 0000000000..3f0f516ef9 --- /dev/null +++ b/umbraco/presentation/umbraco/Trees/RelationTypes/TreeMenu/ActionNewRelationType.cs @@ -0,0 +1,85 @@ +using System; +using umbraco; +using umbraco.interfaces; + +namespace Umbraco.RelationTypes.TreeMenu +{ + /// + /// Create new Relation Type - an Umbraco tree context menu action + /// + public class ActionNewRelationType : IAction + { + /// + /// Private field for the singleton instance + /// + private static readonly ActionNewRelationType instance = new ActionNewRelationType(); + + /// + /// Gets a singleton instance of this action + /// + public static ActionNewRelationType Instance + { + get { return instance; } + } + + #region IAction Members + + /// + /// Gets a string alias used to identify this action + /// + public string Alias + { + get { return "create"; } + } + + /// + /// Gets a unique char to associate with this action + /// + public char Letter + { + get { return '®'; } + } + + /// + /// Gets a value indicating whether the Umbraco notification area is used ? + /// + public bool ShowInNotifier + { + get { return false; } + } + + /// + /// Gets a value indicating whether this action can be configured for use only by specific members + /// + public bool CanBePermissionAssigned + { + get { return false; } // Since this tree is in the developer section, no further granular permissions are required + } + + /// + /// Gets an icon to be used for the right click action + /// + public string Icon + { + get { return ".sprNew"; } // .sprNew refers to an existing sprite + } + + /// + /// Gets a string for the javascript source + /// + public string JsSource + { + get { return "/umbraco/Trees/RelationTypes/TreeMenu/ActionNewRelationType.js"; } + } + + /// + /// Gets a javascript string to execute when this action is fired + /// + public string JsFunctionName + { + get { return "javascript:actionNewRelationType();"; } + } + + #endregion + } +} diff --git a/umbraco/presentation/umbraco/Trees/RelationTypes/TreeMenu/ActionNewRelationType.js b/umbraco/presentation/umbraco/Trees/RelationTypes/TreeMenu/ActionNewRelationType.js new file mode 100644 index 0000000000..2f2489bed0 --- /dev/null +++ b/umbraco/presentation/umbraco/Trees/RelationTypes/TreeMenu/ActionNewRelationType.js @@ -0,0 +1,3 @@ +function actionNewRelationType() { + UmbClientMgr.openModalWindow('Trees/RelationTypes/NewRelationType.aspx', 'Create New RelationType', true, 400, 280, 0, 0); +} \ No newline at end of file diff --git a/umbraco/presentation/web.config b/umbraco/presentation/web.config index 40048a89d6..b01f5259ab 100644 --- a/umbraco/presentation/web.config +++ b/umbraco/presentation/web.config @@ -39,8 +39,8 @@ - - + +