Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
5d219674
Unverified
Commit
5d219674
authored
4 years ago
by
mattwire
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #19065 from colemanw/campaignTabs
Minor tabs cleanup toward fixing
#2215
parents
1bc5c7ab
d9774ef0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Campaign/Page/DashBoard.php
+11
-8
11 additions, 8 deletions
CRM/Campaign/Page/DashBoard.php
templates/CRM/common/TabHeader.js
+60
-58
60 additions, 58 deletions
templates/CRM/common/TabHeader.js
with
71 additions
and
66 deletions
CRM/Campaign/Page/DashBoard.php
+
11
−
8
View file @
5d219674
...
...
@@ -29,6 +29,8 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page {
private
static
$_surveyActionLinks
;
private
static
$_petitionActionLinks
;
public
$_tabs
;
/**
* Get the action links for this page.
*
...
...
@@ -439,6 +441,7 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page {
];
$subPageType
=
CRM_Utils_Request
::
retrieve
(
'type'
,
'String'
,
$this
);
// Load the data for a specific tab
if
(
$subPageType
)
{
if
(
!
isset
(
$this
->
_tabs
[
$subPageType
]))
{
CRM_Utils_System
::
permissionDenied
();
...
...
@@ -447,17 +450,10 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page {
$this
->
{
'browse'
.
ucfirst
(
$subPageType
)}();
$this
->
assign
(
'subPageType'
,
ucfirst
(
$subPageType
));
}
// Initialize tabs
else
{
//build the tabs.
$this
->
buildTabs
();
}
CRM_Core_Resources
::
singleton
()
->
addScriptFile
(
'civicrm'
,
'templates/CRM/common/TabHeader.js'
,
1
,
'html-header'
)
->
addSetting
([
'tabSettings'
=>
[
'active'
=>
strtolower
(
CRM_Utils_Array
::
value
(
'subPage'
,
$_GET
,
'campaign'
)),
],
]);
}
/**
...
...
@@ -485,6 +481,13 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page {
}
$allTabs
[
'campaign'
][
'class'
]
=
'livePage'
;
$this
->
assign
(
'tabHeader'
,
$allTabs
);
CRM_Core_Resources
::
singleton
()
->
addScriptFile
(
'civicrm'
,
'templates/CRM/common/TabHeader.js'
,
1
,
'html-header'
)
->
addSetting
([
'tabSettings'
=>
[
'active'
=>
strtolower
(
CRM_Utils_Array
::
value
(
'subPage'
,
$_GET
,
'campaign'
)),
],
]);
}
}
This diff is collapsed.
Click to expand it.
templates/CRM/common/TabHeader.js
+
60
−
58
View file @
5d219674
// https://civicrm.org/licensing
/**
* By default this simply loads tabs via ajax CRM.loadPage method
* Tabs with class 'ajaxForm' will use CRM.loadForm instead, suitable for most forms
* Tabs with class 'livePage' will get popup action links, suitable for crud tables
*/
CRM
.
$
(
function
(
$
)
{
var
tabSettings
=
CRM
.
tabSettings
||
{};
tabSettings
.
active
=
tabSettings
.
active
?
$
(
'
#tab_
'
+
tabSettings
.
active
).
prevAll
().
length
:
0
;
$
(
"
#mainTabContainer
"
)
.
on
(
'
tabsbeforeactivate
'
,
function
(
e
,
ui
)
{
// CRM-14353 - Warn of unsaved changes for all forms except those which have opted out
if
(
CRM
.
utils
.
initialValueChanged
(
$
(
'
form:not([data-warn-changes=false])
'
,
ui
.
oldPanel
)))
{
CRM
.
alert
(
ts
(
'
Your changes in the <em>%1</em> tab have not been saved.
'
,
{
1
:
ui
.
oldTab
.
text
()}),
ts
(
'
Unsaved Changes
'
),
'
warning
'
);
}
})
.
on
(
'
tabsbeforeload
'
,
function
(
e
,
ui
)
{
// Use civicrm ajax wrappers rather than the default $.load
if
(
!
ui
.
panel
.
data
(
"
civiCrmSnippet
"
))
{
var
method
=
ui
.
tab
.
hasClass
(
'
ajaxForm
'
)
?
'
loadForm
'
:
'
loadPage
'
;
var
params
=
{
target
:
ui
.
panel
};
if
(
method
===
'
loadForm
'
)
{
params
.
autoClose
=
params
.
openInline
=
params
.
cancelButton
=
params
.
refreshAction
=
false
;
ui
.
panel
.
on
(
'
crmFormLoad
'
,
function
()
{
// Hack: "Save and done" and "Cancel" buttons submit without ajax
$
(
'
.cancel.crm-form-submit, button[name$=upload_done]
'
,
this
).
on
(
'
click
'
,
function
(
e
)
{
$
(
this
).
closest
(
'
form
'
).
ajaxFormUnbind
();
});
});
(
function
(
$
,
_
)
{
/**
* By default this simply loads tabs via ajax CRM.loadPage method
* Tabs with class 'ajaxForm' will use CRM.loadForm instead, suitable for most forms
* Tabs with class 'livePage' will get popup action links, suitable for crud tables
*/
$
(
function
(
$
)
{
// CRM.tabSettings.active is the name of the tab which should open on page load
var
tabSettings
=
CRM
.
tabSettings
?
_
.
cloneDeep
(
CRM
.
tabSettings
)
:
{};
tabSettings
.
active
=
tabSettings
.
active
?
$
(
'
#tab_
'
+
tabSettings
.
active
).
prevAll
().
length
:
0
;
$
(
"
#mainTabContainer
"
)
.
on
(
'
tabsbeforeactivate
'
,
function
(
e
,
ui
)
{
// CRM-14353 - Warn of unsaved changes for all forms except those which have opted out
if
(
CRM
.
utils
.
initialValueChanged
(
$
(
'
form:not([data-warn-changes=false])
'
,
ui
.
oldPanel
)))
{
CRM
.
alert
(
ts
(
'
Your changes in the <em>%1</em> tab have not been saved.
'
,
{
1
:
ui
.
oldTab
.
text
()}),
ts
(
'
Unsaved Changes
'
),
'
warning
'
);
}
if
(
ui
.
tab
.
hasClass
(
'
livePage
'
)
&&
CRM
.
config
.
ajaxPopupsEnabled
)
{
})
.
on
(
'
tabsbeforeload
'
,
function
(
e
,
ui
)
{
// Use civicrm ajax wrappers rather than the default $.load
if
(
!
ui
.
panel
.
data
(
"
civiCrmSnippet
"
))
{
var
method
=
ui
.
tab
.
hasClass
(
'
ajaxForm
'
)
?
'
loadForm
'
:
'
loadPage
'
;
var
params
=
{
target
:
ui
.
panel
};
if
(
method
===
'
loadForm
'
)
{
params
.
autoClose
=
params
.
openInline
=
params
.
cancelButton
=
params
.
refreshAction
=
false
;
ui
.
panel
.
on
(
'
crmFormLoad
'
,
function
()
{
// Hack: "Save and done" and "Cancel" buttons submit without ajax
$
(
'
.cancel.crm-form-submit, button[name$=upload_done]
'
,
this
).
on
(
'
click
'
,
function
(
e
)
{
$
(
this
).
closest
(
'
form
'
).
ajaxFormUnbind
();
});
});
}
if
(
ui
.
tab
.
hasClass
(
'
livePage
'
)
&&
CRM
.
config
.
ajaxPopupsEnabled
)
{
ui
.
panel
.
off
(
'
click.crmLivePage
'
)
.
on
(
'
click.crmLivePage
'
,
'
a.button, a.action-item
'
,
CRM
.
popup
)
.
on
(
'
crmPopupFormSuccess.crmLivePage
'
,
'
a.button, a.action-item:not(.crm-enable-disable)
'
,
CRM
.
refreshParent
);
}
ui
.
panel
.
off
(
'
click.crmLivePage
'
)
.
on
(
'
c
lick.crmLivePage
'
,
'
a.button, a.action-item
'
,
CRM
.
popup
)
.
on
(
'
crmPopupFormSuccess.crmLivePage
'
,
'
a.button, a.action-item:not(.crm-enable-disable)
'
,
CRM
.
refreshParent
);
}
ui
.
panel
.
off
(
'
.tabInfo
'
)
.
on
(
'
crmLoad.tabInfo crmFormSuccess.tabInfo
'
,
function
(
e
,
data
)
{
if
(
data
)
{
if
(
typeof
(
data
.
tabCount
)
!==
'
undefin
ed
'
)
{
CRM
.
tabHeader
.
updateCount
(
ui
.
tab
,
data
.
tabCount
);
.
off
(
'
.tabInfo
'
)
.
on
(
'
c
rmLoad.tabInfo crmFormSuccess.tabInfo
'
,
function
(
e
,
data
)
{
if
(
data
)
{
if
(
typeof
(
data
.
tabCount
)
!==
'
undefined
'
)
{
CRM
.
tabHeader
.
updateCount
(
ui
.
tab
,
data
.
tabCount
);
}
if
(
typeof
(
data
.
tabValid
)
!==
'
undefined
'
)
{
var
method
=
data
.
tabValid
?
'
removeClass
'
:
'
addClass
'
;
ui
.
tab
[
method
](
'
disabl
ed
'
)
;
}
}
if
(
typeof
(
data
.
tabValid
)
!==
'
undefined
'
)
{
var
method
=
data
.
tabValid
?
'
removeClass
'
:
'
addClass
'
;
ui
.
tab
[
method
](
'
disabled
'
);
}
}
});
CRM
[
method
](
$
(
'
a
'
,
ui
.
tab
).
attr
(
'
href
'
),
params
);
});
CRM
[
method
](
$
(
'
a
'
,
ui
.
tab
).
attr
(
'
href
'
),
params
);
}
e
.
preventDefault
();
})
.
tabs
(
tabSettings
);
// Any load/submit event could potentially call for tabs to refresh.
$
(
document
).
on
(
'
crmLoad.tabInfo crmFormSuccess.tabInfo
'
,
function
(
e
,
data
)
{
if
(
data
&&
$
.
isPlainObject
(
data
.
updateTabs
))
{
$
.
each
(
data
.
updateTabs
,
CRM
.
tabHeader
.
updateCount
);
$
.
each
(
data
.
updateTabs
,
CRM
.
tabHeader
.
resetTab
);
}
e
.
preventDefault
();
})
.
tabs
(
tabSettings
);
// Any load/submit event could potentially call for tabs to refresh.
$
(
document
).
on
(
'
crmLoad.tabInfo crmFormSuccess.tabInfo
'
,
function
(
e
,
data
)
{
if
(
data
&&
$
.
isPlainObject
(
data
.
updateTabs
))
{
$
.
each
(
data
.
updateTabs
,
CRM
.
tabHeader
.
updateCount
);
$
.
each
(
data
.
updateTabs
,
CRM
.
tabHeader
.
resetTab
);
}
});
});
});
(
function
(
$
)
{
// Utility functions
CRM
.
tabHeader
=
CRM
.
tabHeader
||
{};
...
...
@@ -146,4 +148,4 @@ CRM.$(function($) {
$panel
.
crmSnippet
(
'
destroy
'
);
}
};
})(
CRM
.
$
);
})(
CRM
.
$
,
CRM
.
_
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment