From c6b1ab151f3d236721c7b1285aff796bbaa1e300 Mon Sep 17 00:00:00 2001 From: Yasuyuki Takeo Date: Tue, 1 Jun 2021 18:37:38 +0900 Subject: [PATCH 1/7] Revamp libraries --- .gitignore | 2 ++ gradle/wrapper/gradle-wrapper.properties | 2 +- package.json | 8 ++++---- .../liferay/support/tools/utils/JqueryResolver.java | 13 +++++++++++++ 4 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/liferay/support/tools/utils/JqueryResolver.java diff --git a/.gitignore b/.gitignore index 762bf42..8e199a1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ bin .settings .idea *.iml +package-lock.json +node_modules diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d77c131..870db93 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ #Wed Apr 08 16:42:57 JST 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists diff --git a/package.json b/package.json index b798dbf..c424f46 100644 --- a/package.json +++ b/package.json @@ -2,12 +2,12 @@ "name": "liferay-dummy-factory", "version": "1.0.0", "dependencies": { - "jquery": "^3.5.1", - "lodash": "^4.17.20" + "jquery": "^3.6.0", + "lodash": "^4.17.21" }, "devDependencies": { - "@liferay/npm-scripts": "^34.0.1", - "liferay-npm-bundler": "^2.20.0" + "@liferay/npm-scripts": "^45.0.0", + "liferay-npm-bundler": "^2.24.3" }, "scripts": { "build": "liferay-npm-bundler" diff --git a/src/main/java/com/liferay/support/tools/utils/JqueryResolver.java b/src/main/java/com/liferay/support/tools/utils/JqueryResolver.java new file mode 100644 index 0000000..8c9fd1d --- /dev/null +++ b/src/main/java/com/liferay/support/tools/utils/JqueryResolver.java @@ -0,0 +1,13 @@ +package com.liferay.support.tools.utils; + +import com.liferay.frontend.js.loader.modules.extender.npm.JSPackage; +import com.liferay.frontend.js.loader.modules.extender.npm.NPMResolver; + +import javax.portlet.RenderRequest; + +public class JqueryResolver { + static public void exec(RenderRequest renderRequest, NPMResolver npmResolver) { + JSPackage jsPackage = npmResolver.getDependencyJSPackage("jquery"); + renderRequest.setAttribute("jqueryResolver", jsPackage.getResolvedId()); + } +} From 286f7ee015ac9d2ef460fb0b53fa704cfa5b3365 Mon Sep 17 00:00:00 2001 From: Yasuyuki Takeo Date: Wed, 25 Aug 2021 14:59:29 +0900 Subject: [PATCH 2/7] Fix option panel issue --- .gitignore | 2 + .../resources/META-INF/resources/view.jsp | 224 ++++++++++-------- 2 files changed, 125 insertions(+), 101 deletions(-) diff --git a/.gitignore b/.gitignore index 8e199a1..ae9cc1e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ bin *.iml package-lock.json node_modules +.classpath +.project diff --git a/src/main/resources/META-INF/resources/view.jsp b/src/main/resources/META-INF/resources/view.jsp index a6eb626..44f8c97 100644 --- a/src/main/resources/META-INF/resources/view.jsp +++ b/src/main/resources/META-INF/resources/view.jsp @@ -1,112 +1,134 @@ -<%@ include file="/init.jsp"%> +<%@ include file="/init.jsp" %> - +
- - - - - <%@ include file="/command_select.jspf"%> - - - - - -
-

Create organizations   - -

-
- - - <% - String numberOfOrganizationsLabel = "Enter the number of organizations you would like to create"; - String baseOrganizationNameLabel = "Enter the base name for the organizations"; - String parentOrganizationIdLabel = "Select the parent organization"; - String organizationSiteCreateLabel = "Creating organization site"; - %> - - - - - - - - - 1 - - - - - - - <% - //Organization - List organizations = OrganizationLocalServiceUtil.getOrganizations(QueryUtil.ALL_POS, QueryUtil.ALL_POS); - String defaultOption = "(None)"; - %> - - - - - - - -<% -// Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. -String progressSessionKey = ProgressTracker.PERCENT + progressId; -request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); -%> - - -
-
- + + + + + <%@ include file="/command_select.jspf" %> + + + + + +
+

Create organizations   + +

+
+ + + <% + String numberOfOrganizationsLabel = "Enter the number of organizations you would like to create"; + String baseOrganizationNameLabel = "Enter the base name for the organizations"; + String parentOrganizationIdLabel = "Select the parent organization"; + String organizationSiteCreateLabel = "Creating organization site"; + %> + + + + + + + + + 1 + + + + + + + <% + //Organization + List organizations = OrganizationLocalServiceUtil.getOrganizations(QueryUtil.ALL_POS, QueryUtil.ALL_POS); + String defaultOption = "(None)"; + %> + +
+ + +
+
+
+ + + + <% + for (Organization organization : organizations) { + %> + + <% + } + %> + + + + + +
+
+
+
+ + + + +
+ + <% + // Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. + String progressSessionKey = ProgressTracker.PERCENT + progressId; + request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); + %> + + +
+
+
- function execCommand() { - <%= progressId %>.startProgress(); - submitForm(document.fm); - } + function execCommand() { + <%= progressId %>.startProgress(); + submitForm(document.fm); + } From f64351911206090d08b40d8de1d87e4f447b6f6e Mon Sep 17 00:00:00 2001 From: Yasuyuki Takeo Date: Fri, 27 Aug 2021 14:08:35 +0900 Subject: [PATCH 3/7] remove JQuery --- .../resources/META-INF/resources/blogs.jsp | 247 ++++---- .../resources/META-INF/resources/category.jsp | 581 +++++++++--------- .../resources/META-INF/resources/company.jsp | 37 +- .../META-INF/resources/documents.jsp | 464 +++++++------- src/main/resources/META-INF/resources/mb.jsp | 337 +++++----- .../resources/META-INF/resources/pages.jsp | 363 ++++++----- .../resources/META-INF/resources/sites.jsp | 301 +++++---- .../resources/META-INF/resources/view.jsp | 29 +- 8 files changed, 1252 insertions(+), 1107 deletions(-) diff --git a/src/main/resources/META-INF/resources/blogs.jsp b/src/main/resources/META-INF/resources/blogs.jsp index 5d243d0..5b1cae7 100644 --- a/src/main/resources/META-INF/resources/blogs.jsp +++ b/src/main/resources/META-INF/resources/blogs.jsp @@ -1,131 +1,152 @@ - -<%@ include file="/init.jsp"%> +<%@ include file="/init.jsp" %>
- - - - - <%@ include file="/command_select.jspf"%> - - - - - -
-

Create Blog posts   - -

+ + + + + <%@ include file="/command_select.jspf" %> + + + + + + + - - - function execCommand() { - <%= progressId %>.startProgress(); - submitForm(document.fm); - } + function execCommand() { + <%= progressId %>.startProgress(); + submitForm(document.fm); + } \ No newline at end of file diff --git a/src/main/resources/META-INF/resources/category.jsp b/src/main/resources/META-INF/resources/category.jsp index 6f958f9..2da84c7 100644 --- a/src/main/resources/META-INF/resources/category.jsp +++ b/src/main/resources/META-INF/resources/category.jsp @@ -1,323 +1,326 @@ -<%@ include file="/init.jsp"%> +<%@ include file="/init.jsp" %>
- - - - - <%@ include file="/command_select.jspf"%> - - - - - - -
-

Create Category / Vocabulary   - -

-
- - - - <% - String numberOfCategoriesLabel = "Enter the number of categories / vocabralies you would like to create"; - String baseCategoryNameLabel= "Enter the base Category / Vocabulary name"; - List groups = GroupLocalServiceUtil.getGroups(QueryUtil.ALL_POS, QueryUtil.ALL_POS); - final String groupName = GroupConstants.GUEST; - final long companyId = PortalUtil.getDefaultCompanyId(); - final long guestGroupId = GroupLocalServiceUtil.getGroup(companyId, groupName).getGroupId(); - - String defaultOption = "(None)"; - - String scopeGroupdId = String.valueOf(themeDisplay.getScopeGroupId()); - String groupLabel = "Select a site to assign the pages to"; - String pageLabel = "Select a parent page"; - String createContentsTypeLabel = "Select create type"; - String parentCategoryIdLabel = "Enter the parent category ID"; - String privateLayoutLabel = "Make pages private"; - String hiddenLabel = "Hide from Navigation Menu"; - String vocabularyIdLabel = "Vocabulary ID"; - %> - - - - - - - - - - - - - - <% - for (Group group : groups) { - if (group.isSite()) { - %> - - <% - } - } - %> - + + + + + <%@ include file="/command_select.jspf" %> + + + + + + + + + + + <% + String numberOfCategoriesLabel = "Enter the number of categories / vocabralies you would like to create"; + String baseCategoryNameLabel = "Enter the base Category / Vocabulary name"; + List groups = GroupLocalServiceUtil.getGroups(QueryUtil.ALL_POS, QueryUtil.ALL_POS); + final String groupName = GroupConstants.GUEST; + final long companyId = PortalUtil.getDefaultCompanyId(); + final long guestGroupId = GroupLocalServiceUtil.getGroup(companyId, groupName).getGroupId(); - + String defaultOption = "(None)"; + + String groupLabel = "Select a site to assign the pages to"; + String createContentsTypeLabel = "Select create type"; + String parentCategoryIdLabel = "Enter the parent category ID"; + String vocabularyIdLabel = "Vocabulary ID"; + %> + + + + + + + + + + + + + + <% + for (Group group : groups) { + if (group.isSite()) { + %> + + <% + } + } + %> + + + <% - List assetVocabularies = AssetVocabularyServiceUtil.getGroupVocabularies( - guestGroupId, true); + List assetVocabularies = AssetVocabularyServiceUtil.getGroupVocabularies( + guestGroupId, true); - %> + %> - - <% - for (AssetVocabulary assetVocabulary : assetVocabularies) { - %> - - <% - } - %> - - - - (None) - + + <% + for (AssetVocabulary assetVocabulary : assetVocabularies) { + %> + + <% + } + %> + + + + (None) + - - - 1 - - function() { - return (<%= String.valueOf(LDFPortletKeys.C_CATEGORY_CREATE) %> == $('#createContentsType').val()); - } - - - - - - function() { - return (<%= String.valueOf(LDFPortletKeys.C_CATEGORY_CREATE) %> == $('#createContentsType').val()); - } - - + + + 1 + + function() { + return (<%= String.valueOf(LDFPortletKeys.C_CATEGORY_CREATE) %> == document.getElementById('createContentsType').value); + } + + + + + + function() { + return (<%= String.valueOf(LDFPortletKeys.C_CATEGORY_CREATE) %> == document.getElementById('createContentsType').value); + } + + - <% - String numberOfVocabularyLabel = "Number of vocabulary"; - String baseVocabularyNameLabel = "Base Vocabulary Name"; - %> - -<% -// Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. -String progressSessionKey = ProgressTracker.PERCENT + progressId; -request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); -%> - - - + + + + + <% + // Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. + String progressSessionKey = ProgressTracker.PERCENT + progressId; + request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); + %> + +
+
- function execCommand() { - <%= progressId %>.startProgress(); - submitForm(document.fm); - } + function execCommand() { + console.log("in"); + <%= progressId %>.startProgress(); + submitForm(document.fm); + } - + // Manage GroupID list display - var createContentsType = A.one('#createContentsType'); - $('#createContentsType').on( - 'change load', - function() { - //-------------------------------- - // Contents Creation fields switch - //-------------------------------- - var cmp_str = "contentsType" + createContentsType.val(); - - $('.contentsTypeGroup').each(function(index){ - $(this).toggle((cmp_str === $(this).attr("id"))); - }); - } - ); + var createContentsType = document.getElementById('createContentsType'); + createContentsType.addEventListener("change load", function() { + //-------------------------------- + // Contents Creation fields switch + //-------------------------------- + var cmp_str = "contentsType" + createContentsType.value; + var ctg = document.getElementsByClassName("contentsTypeGroup"); + for (var i = 0; i < ctg.length; i++) { + ctg[i].style.display = (cmp_str === document.getElementById(this).getAttribute("id")) ? "block" : "none"; + } + }); <%-- Thread List Update --%> - + - - // Update category list - function categoryListUpdate() { - var defer = $.Deferred(); - - Liferay.Service( - '/assetcategory/get-vocabulary-categories', - { - vocabularyId:$('#vocabularyId').val() , - start: -1 , - end: -1, - "+obc":"com.liferay.portlet.asset.util.comparator.AssetCategoryCreateDateComparator" - }, - function(dataIn) { - var data = dataIn; - - Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { - (function() { - var _ = _lodash; - - //Load Template - var tmpl = _.template($('#category_options').html()); - var listAll = tmpl({ - categoryId:"<%= String.valueOf(AssetCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) %>", - categoryName:"(None)", - selected:"true" - }); - - _.map(data,function(n) { - listAll += - tmpl( - { - categoryId:(n.categoryId) ? _.escape(n.categoryId) : "", - categoryName:(n.titleCurrentValue) ? _.escape(n.titleCurrentValue) : "", - selected:"false" - } - ); - }); - var catObj = $('#parentCategoryId'); - catObj.empty(); - catObj.append(listAll); - defer.resolve(); - - })() - }, function(error) { - console.error(error) - }); - - } - ); - return defer.promise(); - } - - // Vocabulary ID - $('#vocabularyId').on( - 'change load', - function(event) { - //Update thread list - categoryListUpdate(); - } - ); - - // Group (Site) - $('#group').on( - 'change load', - function(event) { - - //Update thread list - vocabularyUpdate() - .then(function() { - categoryListUpdate(); - }); - } - ); - - // Update vocabulary list - function vocabularyUpdate() { - var defer = $.Deferred(); - - $('#group').on( - 'change load', - function(event) { - Liferay.Service( - '/assetvocabulary/get-group-vocabularies', - { - groupId: $('#group').val() - }, - function(dataIn) { - var data = dataIn; - - Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { - (function() { - var _ = _lodash; - - //Load Template - var tmpl = _.template($('#vocabulary_options').html()); - var listAll = ""; - _.map(data,function(n) { - listAll += - tmpl({ - vocabularyId:(n.vocabularyId) ? _.escape(n.vocabularyId) : "", - vocabularyName:(n.titleCurrentValue) ? _.escape(n.titleCurrentValue) : "" - }); - }); - var catObj = $('#vocabularyId'); - catObj.empty(); - catObj.append(listAll); - defer.resolve(); - - })() - }, function(error) { - console.error(error) - }); - } - ); - } - ); - return defer.promise(); - } - \ No newline at end of file + // Update category list + function categoryListUpdate() { + var defer = $.Deferred(); + + Liferay.Service( + '/assetcategory/get-vocabulary-categories', + { + vocabularyId:document.getElementById('vocabularyId').value , + start: -1 , + end: -1, + "+obc":"com.liferay.portlet.asset.util.comparator.AssetCategoryCreateDateComparator" + }, + function(dataIn) { + var data = dataIn; + + Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { + (function() { + var _ = _lodash; + + //Load Template + var tmpl = _.template(document.getElementById('category_options').innerHTML); + var listAll = tmpl({ + categoryId:"<%= String.valueOf(AssetCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) %>", + categoryName:"(None)", + selected:"true" + }); + + _.map(data,function(n) { + listAll += + tmpl( + { + categoryId:(n.categoryId) ? _.escape(n.categoryId) : "", + categoryName:(n.titleCurrentValue) ? _.escape(n.titleCurrentValue) : "", + selected:"false" + } + ); + }); + var catObj = document.getElementById('parentCategoryId'); + catObj.empty(); + catObj.append(listAll); + defer.resolve(); + + })() + }, function(error) { + console.error(error) + }); + + } + ); + return defer.promise(); + } + + // Vocabulary ID + document.getElementById('vocabularyId') + .addEventListener("change load", function(event) { + //Update thread list + categoryListUpdate(); + }) + + // Group (Site) + document.getElementById('group') + .addEventListener("change load", function(event) { + //Update thread list + console.log("in"); + vocabularyUpdate() + .then(function() { + categoryListUpdate(); + }); + }) + + function Deferred (){ + let res,rej,p = new Promise((a,b)=>(res = a, rej = b)); + p.resolve = res; + p.reject = rej; + return p; + } + + // Update vocabulary list + function vocabularyUpdate() { + var defer = Deferred(); + document.getElementById('group') + .addEventListener("change load", function(event) { + Liferay.Service( + '/assetvocabulary/get-group-vocabularies', + { + groupId: document.getElementById('group').value + }, + function(dataIn) { + var data = dataIn; + + Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { + (function() { + var _ = _lodash; + + //Load Template + var tmpl = _.template(document.getElementById('vocabulary_options').innerHTML); + var listAll = ""; + _.map(data,function(n) { + listAll += + tmpl({ + vocabularyId:(n.vocabularyId) ? _.escape(n.vocabularyId) : "", + vocabularyName:(n.titleCurrentValue) ? _.escape(n.titleCurrentValue) : "" + }); + }); + var catObj = document.getElementById('vocabularyId'); + catObj.empty(); + catObj.append(listAll); + defer.resolve(); + + })() + }, function(error) { + console.error(error) + }); + } + ); + }) + + return defer.resolve(); + } + diff --git a/src/main/resources/META-INF/resources/company.jsp b/src/main/resources/META-INF/resources/company.jsp index fbfaecf..34da30e 100644 --- a/src/main/resources/META-INF/resources/company.jsp +++ b/src/main/resources/META-INF/resources/company.jsp @@ -16,25 +16,28 @@ - -
-

Create Companies   - -

-
- - <% String numberOfCompaniesLabel= "Enter the number of companies you would like to create"; diff --git a/src/main/resources/META-INF/resources/documents.jsp b/src/main/resources/META-INF/resources/documents.jsp index e60fed4..08634d7 100644 --- a/src/main/resources/META-INF/resources/documents.jsp +++ b/src/main/resources/META-INF/resources/documents.jsp @@ -1,248 +1,286 @@ -<%@ include file="/init.jsp"%> +<%@ include file="/init.jsp" %>
- - - - - <%@ include file="/command_select.jspf"%> - - - - - + + + + + <%@ include file="/command_select.jspf" %> + + + + +

Create Documents   -

- - function execCommand() { - <%= progressId %>.startProgress(); - submitForm(document.fm); - } + function execCommand() { + <%= progressId %>.startProgress(); + submitForm(document.fm); + } + var handleClick = function (event) { + Liferay.Service( + '/dlfolder/get-folders', + { + groupId: document.getElementById('groupId').value, + parentFolderId: "<%= String.valueOf(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) %>", + start: -1, + end: -1, + "+obc": "com.liferay.document.library.kernel.util.comparator.FolderIdComparator" + }, + function (dataIn) { + var data = dataIn; - $('#groupId').on( - 'change load', - function(event) { - - Liferay.Service( - '/dlfolder/get-folders', - { - groupId: $('#groupId').val(), - parentFolderId: "<%= String.valueOf(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) %>", - start: -1, - end: -1, - "+obc":"com.liferay.document.library.kernel.util.comparator.FolderIdComparator" - }, - function(dataIn) { - var data = dataIn; - //Load Template - Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { - (function() { - var _ = _lodash; - - var tmpl = _.template($('#journal_folder_options').html()); - var listAll = tmpl({ - folderId:"<%= String.valueOf(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) %>", - name:"(None)", - selected:"true" - }); - - _.map(data,function(n) { - listAll += - tmpl( - { - folderId:(n.folderId) ? _.escape(n.folderId) : "", - name:(n.name) ? _.escape(n.name) : "", - selected:"false" - } - ); - }); - var catObj = $('#folderId'); - catObj.empty(); - catObj.append(listAll); - - })() - }, function(error) { - console.error(error) - }); - - } - ); - } - ); + Liferay.Loader.require("<%=lodashResolver %>", function (_lodash) { + (function () { + var _ = _lodash; + + var tmpl = _.template(document.getElementById('journal_folder_options').innerHTML); + var listAll = tmpl({ + folderId: "<%= String.valueOf(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) %>", + name: "(None)", + selected: "true" + }); + + _.map(data, function (n) { + listAll += + tmpl( + { + folderId: (n.folderId) ? _.escape(n.folderId) : "", + name: (n.name) ? _.escape(n.name) : "", + selected: "false" + } + ); + }); + var catObj = document.getElementById('folderId'); + catObj.empty(); + catObj.append(listAll); + + })() + }, function (error) { + console.error(error) + }); + + } + ); + } + + // Register listeners to the dom + var elm = document.createElement("groupId"); + elm.addEventListener("change load", handleClick); diff --git a/src/main/resources/META-INF/resources/mb.jsp b/src/main/resources/META-INF/resources/mb.jsp index 87818af..2b38924 100644 --- a/src/main/resources/META-INF/resources/mb.jsp +++ b/src/main/resources/META-INF/resources/mb.jsp @@ -17,29 +17,30 @@ - -
-

Create Message Board   - -

-
- - <% String numberOfMBLabel= "Enter the number of threads / categories you would like to create"; - String baseTitleLabel= "Enter the base title"; - String baseArticleLabel = "Enter the contents"; String defaultOption = "(None)"; String groupIdLabel = "Select a site to assign the threads / categories to"; String createContentsTypeLabel = "Select create type"; @@ -60,7 +61,8 @@ final long guestGroupId = GroupLocalServiceUtil.getGroup(companyId, groupName).getGroupId(); %> - + @@ -119,14 +121,14 @@ function() { - return (<%= String.valueOf(LDFPortletKeys.MB_THREAD_CREATE) %> == AUI.$('#createContentsType').val()); + return (<%= String.valueOf(LDFPortletKeys.MB_THREAD_CREATE) %> == document.getElementById('createContentsType').value); } function() { - return (<%= String.valueOf(LDFPortletKeys.MB_THREAD_CREATE) %> == AUI.$('#createContentsType').val()); + return (<%= String.valueOf(LDFPortletKeys.MB_THREAD_CREATE) %> == document.getElementById('createContentsType').value); } @@ -151,14 +153,14 @@ function() { - return (<%= String.valueOf(LDFPortletKeys.MB_CATEGORY_CREATE) %> == AUI.$('#createContentsType').val()); + return (<%= String.valueOf(LDFPortletKeys.MB_CATEGORY_CREATE) %> == document.getElementById('createContentsType').value); } function() { - return (<%= String.valueOf(LDFPortletKeys.MB_CATEGORY_CREATE) %> == AUI.$('#createContentsType').val()); + return (<%= String.valueOf(LDFPortletKeys.MB_CATEGORY_CREATE) %> == document.getElementById('createContentsType').value); } @@ -169,11 +171,11 @@ -<% -// Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. -String progressSessionKey = ProgressTracker.PERCENT + progressId; -request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); -%> + <% + // Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. + String progressSessionKey = ProgressTracker.PERCENT + progressId; + request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); + %> - // Manage GroupID list display - var createContentsType = A.one('#createContentsType'); - $('#createContentsType').on( - 'change load', - function() { - //-------------------------------- - // Contents Creation fields switch - //-------------------------------- - var cmp_str = "contentsType" + createContentsType.val(); - - $('.contentsTypeGroup').each(function(index){ - $(this).toggle((cmp_str === $(this).attr("id"))); - }); - - //-------------------------------- - // At reply create, remove multiple for select site. - //-------------------------------- - if(<%= String.valueOf(LDFPortletKeys.MB_REPLY_CREATE) %> == createContentsType.val()) { - $("#siteGroupIdWrap").show(); - $("#contentsType<%= String.valueOf(LDFPortletKeys.MB_THREAD_CREATE) %>").show(); - $("#categoryIdWrap").hide(); - $("#groupIdsWrap").hide(); - - //Update thread list - threadListUpdate(); - } else if(<%= String.valueOf(LDFPortletKeys.MB_CATEGORY_CREATE) %> == createContentsType.val()) { - $("#siteGroupIdWrap").show(); - $("#categoryIdWrap").hide(); - $("#groupIdsWrap").hide(); - } else { - $("#siteGroupIdWrap").hide(); - $("#categoryIdWrap").show(); - $("#groupIdsWrap").show(); - } - - } - ); + var createContentsType = document.getElementById('createContentsType'); + var handleClick = function() { + + //-------------------------------- + // Contents Creation fields switch + //-------------------------------- + var cmp_str = "contentsType" + createContentsType.value; + + var ctg = document.getElementsByClassName("contentsTypeGroup"); + for (var i = 0; i < ctg.length; i++) { + console.log(ctg[i]); + ctg[i].style.display = (cmp_str === document.getElementById(this).getAttribute("id")) ? "block" : "none"; + } + + //-------------------------------- + // At reply create, remove multiple for select site. + //-------------------------------- + if(<%= String.valueOf(LDFPortletKeys.MB_REPLY_CREATE) %> == createContentsType.value) { + document.getElementsByClassName("siteGroupIdWrap").style.display = "block"; + document.getElementsByClassName("contentsType<%= String.valueOf(LDFPortletKeys.MB_THREAD_CREATE) %>").style.display = "block"; + document.getElementsByClassName("categoryIdWrap").style.display = "none"; + document.getElementsByClassName("groupIdsWrap").style.display = "none"; + + //Update thread list + threadListUpdate(); + } else if(<%= String.valueOf(LDFPortletKeys.MB_CATEGORY_CREATE) %> == createContentsType.value) { + document.getElementsByClassName("siteGroupIdWrap").style.display = "block"; + document.getElementsByClassName("categoryIdWrap").style.display = "none"; + document.getElementsByClassName("groupIdsWrap").style.display = "none"; + } else { + document.getElementsByClassName("siteGroupIdWrap").style.display = "none"; + document.getElementsByClassName("categoryIdWrap").style.display = "block"; + document.getElementsByClassName("groupIdsWrap").style.display = "block"; + } + + } + // Manage GroupID list display + createContentsType.addEventListener("change load", handleClick); <%-- Thread List Update --%> @@ -244,124 +247,130 @@ request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); - + + function ajax(cmd, path, data, handler) { + var xmlhttp = new XMLHttpRequest(); + + xmlhttp.onreadystatechange = function() { + if (xmlhttp.readyState == XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4 + if (xmlhttp.status == 200) { + var jsonData = JSON.parse(xmlhttp.response); + handler(jsonData) + } + else { + console.error('status: ' + xmlhttp.status); + } + } + }; + + xmlhttp.open(cmd, path, true); + xmlhttp.send(data); + } + // Update thread list function threadListUpdate() { var data = Liferay.Util.ns( '', { <%=Constants.CMD %>: '<%=MBMVCResourceCommand.CMD_THREAD_LIST%>', - siteGroupId: $('#siteGroupId').val() + siteGroupId: document.getElementById('siteGroupId').value } ); - $.ajax( - '<%= mbListURL.toString() %>', - { - data: data, - success: function(dataIn) { - var data = dataIn; - - Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { - (function() { - var _ = _lodash; - - //Load Template - var tmpl = _.template($('#message_options').html()); - var listAll = ""; - _.map(data,function(n) { - listAll += - tmpl( - { - rootMessageSubject:(n.rootMessageSubject) ? _.escape(n.rootMessageSubject) : "", - threadId:(n.threadId) ? _.escape(n.threadId) : "", - rootMessageId:(n.rootMessageId) ? _.escape(n.rootMessageId) : "" - } - ); - }); - var pageObj = $('#threadId'); - pageObj.empty(); - pageObj.append(listAll); - - })() - }, function(error) { - console.error(error) - }); - - } - } - ); + var threadListUpdateHandlerFunc = function(dataIn) { + var data = dataIn; + + Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { + (function() { + var _ = _lodash; + + //Load Template + var tmpl = _.template(document.getElementsByClassName('message_options').innerHTML); + var listAll = ""; + _.map(data,function(n) { + listAll += + tmpl( + { + rootMessageSubject:(n.rootMessageSubject) ? _.escape(n.rootMessageSubject) : "", + threadId:(n.threadId) ? _.escape(n.threadId) : "", + rootMessageId:(n.rootMessageId) ? _.escape(n.rootMessageId) : "" + } + ); + }); + var pageObj = document.getElementsByClassName('threadId'); + pageObj.empty(); + pageObj.append(listAll); + + })() + }, function(error) { + console.error(error) + }); + + } + ajax("POST", '<%= mbListURL.toString() %>', data, threadListUpdateHandlerFunc ) } - + function categoryListUpdate() { var data = Liferay.Util.ns( '', { <%=Constants.CMD %>: '<%=MBMVCResourceCommand.CMD_CATEGORY_LIST%>', - groupIds: $('#groupIds').val().join(',') + groupIds: document.getElementById('groupIds').value.join(',') } ); - $.ajax( - '<%= mbListURL.toString() %>', - { - data: data, - success: function(dataIn) { - var data = dataIn; - - Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { - (function() { - var _ = _lodash; - - //Load Template - var tmpl = _.template($('#category_options').html()); - var listAll = tmpl({ - categoryId:"<%= String.valueOf(MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) %>", - categoryName:"Default" - }); - _.map(data,function(n) { - listAll += - tmpl( - { - categoryId:(n.categoryId) ? _.escape(n.categoryId) : "", - categoryName:(n.categoryName) ? _.escape(n.categoryName) : "" - } - ); - }); - var pageObj = $('#categoryId'); - pageObj.empty(); - pageObj.append(listAll); - - })() - }, function(error) { - console.error(error) - }); - } - } - ); - } - - $('#siteGroupId').on( - 'change load', - function(event) { - //Update thread list - threadListUpdate(); + var categoryListUpdateHandlerFunc = function(dataIn) { + var data = dataIn; + + Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { + (function() { + var _ = _lodash; + + //Load Template + var tmpl = _.template(document.getElementsByClassName('category_options').innerHTML); + var listAll = tmpl({ + categoryId:"<%= String.valueOf(MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) %>", + categoryName:"Default" + }); + _.map(data,function(n) { + listAll += + tmpl( + { + categoryId:(n.categoryId) ? _.escape(n.categoryId) : "", + categoryName:(n.categoryName) ? _.escape(n.categoryName) : "" + } + ); + }); + var pageObj = document.getElementsByClassName('categoryId'); + pageObj.empty(); + pageObj.append(listAll); + + })() + }, function(error) { + console.error(error) + }); } - ); - - $('#groupIds').on( - 'change load', - function(event) { - var groupIds = $(this).val(); - if(groupIds.length == 1) { - //Update category list - $("#categoryIdWrap").show(); - categoryListUpdate(); - } else { - $("#categoryIdWrap").hide(); - } + + ajax("POST", '<%= mbListURL.toString() %>', data, categoryListUpdateHandlerFunc ) + } + + document.createElement("siteGroupId") + .addEventListener("change load", function(event) { + //Update thread list + threadListUpdate(); + }) + + document.createElement("groupIds") + .addEventListener("change load", function(event) { + var groupIds = document.createElement("groupIds").value; + if(groupIds.length == 1) { + //Update category list + document.getElementById("categoryIdWrap").style.display = "block"; + categoryListUpdate(); + } else { + document.getElementById("categoryIdWrap").style.display = "none"; } - ); + }) diff --git a/src/main/resources/META-INF/resources/pages.jsp b/src/main/resources/META-INF/resources/pages.jsp index fcb789d..fd16aba 100644 --- a/src/main/resources/META-INF/resources/pages.jsp +++ b/src/main/resources/META-INF/resources/pages.jsp @@ -1,184 +1,217 @@ -<%@ include file="/init.jsp"%> +<%@ include file="/init.jsp" %>
- - - - - <%@ include file="/command_select.jspf"%> - - - - - -
-

Create Pages   - -

-
- - - - <% - String numberOfPagesLabel= "Enter the number of pages you would like to create"; - String basePageNameLabel= "Enter the base page name (i.e. newPage, page, testPage)"; - List groups = GroupLocalServiceUtil.getGroups(QueryUtil.ALL_POS, QueryUtil.ALL_POS); - String defaultOption = "(None)"; - - String scopeGroupdId = String.valueOf(themeDisplay.getScopeGroupId()); - String groupLabel = "Select a site to assign the pages to"; - String pageLabel = "Select a parent page"; - %> - - - - - - - 1 - - - - - - - - <% - for (Group group : groups) { - if (group.isSite()) { - %> - - <% - } - } - %> - - - - <% - String parentLayoutIdLabel = "Enter the parent page ID"; - String privateLayoutLabel = "Make pages private"; - String hiddenLabel = "Hide from Navigation Menu"; - %> - - - - - - - -<% -// Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. -String progressSessionKey = ProgressTracker.PERCENT + progressId; -request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); -%> - -
-
+ + + + + <%@ include file="/command_select.jspf" %> + + + + + + + + + + + <% + String numberOfPagesLabel = "Enter the number of pages you would like to create"; + String basePageNameLabel = "Enter the base page name (i.e. newPage, page, testPage)"; + List groups = GroupLocalServiceUtil.getGroups(QueryUtil.ALL_POS, QueryUtil.ALL_POS); + String defaultOption = "(None)"; + + String scopeGroupdId = String.valueOf(themeDisplay.getScopeGroupId()); + String groupLabel = "Select a site to assign the pages to"; + String pageLabel = "Select a parent page"; + %> + + + + + + + 1 + + + + + + + + <% + for (Group group : groups) { + if (group.isSite()) { + %> + + <% + } + } + %> + + + + <% + String parentLayoutIdLabel = "Enter the parent page ID"; + String privateLayoutLabel = "Make pages private"; + String hiddenLabel = "Hide from Navigation Menu"; + %> + +
+ +
+ + + + + +
+ <% + // Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. + String progressSessionKey = ProgressTracker.PERCENT + progressId; + request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); + %> + +
+
- function execCommand() { - <%= progressId %>.startProgress(); - submitForm(document.fm); - } + function execCommand() { + <%= progressId %>.startProgress(); + submitForm(document.fm); + } - + + // Ajax + function ajax(cmd, path, data, handler) { + var xmlhttp = new XMLHttpRequest(); + + xmlhttp.onreadystatechange = function() { + if (xmlhttp.readyState == XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4 + if (xmlhttp.status == 200) { + var jsonData = JSON.parse(xmlhttp.response); + handler(jsonData) + } + else { + console.error('status: ' + xmlhttp.status); + } + } + }; + + xmlhttp.open(cmd, path, true); + xmlhttp.send(data); + } + + document.getElementById("group") + .addEventListener("change", function(event) { + var data = Liferay.Util.ns( + '', + { + <%=Constants.CMD %>: '<%=PageMVCResourceCommand.CMD_PAGELIST%>', + siteGroupId: $('#group').val() + } + ); + + ajax("POST", '<%= pagesForASiteURL.toString() %>', data, function(dataIn) { + var data = dataIn; + + Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { + (function() { + var _ = _lodash; + + //Load Template + var tmpl = _.template(document.getElementById('page_per_site_options').innerHTML); + var listAll = + tmpl({ + name:'(None)', + parentLayoutId:0 + }); + _.map(data,function(n) { + listAll += + tmpl( + { + name:(n.name) ? _.escape(n.name) : "", + parentLayoutId:(n.parentLayoutId) ? _.escape(n.parentLayoutId) : "" + } + ); + }); + var pageObj = document.getElementById('parentLayoutId'); + pageObj.empty(); + pageObj.append(listAll); - $('#group').on( - 'change', - function(event) { - var data = Liferay.Util.ns( - '', - { - <%=Constants.CMD %>: '<%=PageMVCResourceCommand.CMD_PAGELIST%>', - siteGroupId: $('#group').val() - } - ); - - $.ajax( - '<%= pagesForASiteURL.toString() %>', - { - data: data, - success: function(dataIn) { - var data = dataIn; - - Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { - (function() { - var _ = _lodash; - - //Load Template - var tmpl = _.template($('#page_per_site_options').html()); - var listAll = - tmpl({ - name:'(None)', - parentLayoutId:0 - }); - _.map(data,function(n) { - listAll += - tmpl( - { - name:(n.name) ? _.escape(n.name) : "", - parentLayoutId:(n.parentLayoutId) ? _.escape(n.parentLayoutId) : "" - } - ); - }); - var pageObj = $('#parentLayoutId'); - pageObj.empty(); - pageObj.append(listAll); - - })() - }, function(error) { - console.error(error) - }); - } - } - ); - } - ); + })() + }, function(error) { + console.error(error) + }); + }); + }); diff --git a/src/main/resources/META-INF/resources/sites.jsp b/src/main/resources/META-INF/resources/sites.jsp index 765ec12..2cdaa7f 100644 --- a/src/main/resources/META-INF/resources/sites.jsp +++ b/src/main/resources/META-INF/resources/sites.jsp @@ -1,144 +1,177 @@ -<%@ include file="/init.jsp"%> +<%@ include file="/init.jsp" %>
- - - - - <%@ include file="/command_select.jspf"%> - - - - - - -
-

Create Sites   - -

-
- - - - <% - String numberOfSitesLabel = "Enter the number of sites you would like to create"; - String baseSiteNameLabel = "Enter the base name for the sites"; - String siteTypeLabel = "Site type"; - %> - - - - - - - - - - - - 1 - - - - - - - <% - String parentGroupIdLabel = "Select the parent site"; - String manualMembershipLabel = "Enable manual membership"; - String inheritContentLabel = "Enable inherit content"; - String activeLabel = "Activate site"; - String publicLayoutSetPrototypeIdLabel = "Site Template"; - - List groups = GroupLocalServiceUtil.getGroups(QueryUtil.ALL_POS, QueryUtil.ALL_POS); - String scopeGroupdId = String.valueOf(themeDisplay.getScopeGroupId()); - String defaultOption = "(None)"; - - List layoutSetPrototypes = LayoutSetPrototypeLocalServiceUtil.search( - themeDisplay.getCompanyId(), true, - QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); - %> - - - - - - - -<% -// Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. -String progressSessionKey = ProgressTracker.PERCENT + progressId; -request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); -%> - -
-
+ + + + + <%@ include file="/command_select.jspf" %> + + + + + + + + + + + <% + String numberOfSitesLabel = "Enter the number of sites you would like to create"; + String baseSiteNameLabel = "Enter the base name for the sites"; + String siteTypeLabel = "Site type"; + %> + + + + + + + + + + + + 1 + + + + + + + <% + String parentGroupIdLabel = "Select the parent site"; + String manualMembershipLabel = "Enable manual membership"; + String inheritContentLabel = "Enable inherit content"; + String activeLabel = "Activate site"; + String publicLayoutSetPrototypeIdLabel = "Site Template"; + + List groups = GroupLocalServiceUtil.getGroups(QueryUtil.ALL_POS, QueryUtil.ALL_POS); + String defaultOption = "(None)"; + + List layoutSetPrototypes = LayoutSetPrototypeLocalServiceUtil.search( + themeDisplay.getCompanyId(), true, + QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); + %> + +
+ +
+ + + + + +
+ <% + // Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. + String progressSessionKey = ProgressTracker.PERCENT + progressId; + request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); + %> + +
+
- function execCommand() { - <%= progressId %>.startProgress(); - submitForm(document.fm); - } + function execCommand() { + <%= progressId %>.startProgress(); + submitForm(document.fm); + } \ No newline at end of file diff --git a/src/main/resources/META-INF/resources/view.jsp b/src/main/resources/META-INF/resources/view.jsp index 44f8c97..45abda1 100644 --- a/src/main/resources/META-INF/resources/view.jsp +++ b/src/main/resources/META-INF/resources/view.jsp @@ -17,14 +17,16 @@ -
-

Create organizations   - -

+ -